trhlina-calendar/main.py

41 lines
1,013 B
Python
Raw Normal View History

2024-02-25 12:01:10 +01:00
from flask import Flask, render_template, request, send_from_directory
2024-02-25 09:13:54 +01:00
import get_json
from dotenv import load_dotenv
import os
import json
2024-02-25 12:01:10 +01:00
from os.path import join, dirname
2024-02-25 09:13:54 +01:00
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():
return render_template('index.html')
2024-02-25 09:13:54 +01:00
@app.route("/events")
def server_json():
with open("events.json") as event_json:
return json.load(event_json)
2024-02-25 09:13:54 +01:00
@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)