trhlina-calendar/main.py
Pták 6427a50272 changes to json events from array
Adds support for webhook creation and init of events.json. I have no clue how i fixed it, or why does it work.
2024-02-25 10:09:00 +01:00

42 lines
1 KiB
Python

from flask import Flask, render_template, request
import get_json
from dotenv import load_dotenv
import os
import json
load_dotenv()
webhook_update_url = os.environ.get("WEBHOOK-URL")
app = Flask(__name__, template_folder='./conf/templates')
@app.route('/favicon.ico')
def favicon():
return send_from_directory(os.path.join(app.root_path, 'static'),
'favicon.ico', mimetype='image/vnd.microsoft.icon')
@app.route('/')
def home():
#events = get_json.main()
#return render_template('index.html', events=events)
return render_template('index.html')
@app.route("/events")
def server_json():
with open("events.json") as event_json:
return json.load(event_json)
@app.route(webhook_update_url, methods=['GET', 'POST'])
def update():
if request.method == 'GET':
return "This is Webhook endpoint that accepts data through POST"
if request.method == 'POST':
get_json.main()
return 201
if __name__ == '__main__':
app.run(host='0.0.0.0', port=80)