forked from NoLog.cz/trhlina-calendar
41 lines
971 B
Python
41 lines
971 B
Python
from flask import Flask, render_template, request
|
|
import get_json
|
|
|
|
from dotenv import load_dotenv
|
|
import os
|
|
|
|
load_dotenv()
|
|
|
|
json_url = os.environ.get("JSON-URL")
|
|
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)
|
|
|
|
@app.route(json_url)
|
|
def summary():
|
|
x = "meme"
|
|
return x
|
|
|
|
@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)
|