from flask import Flask, render_template, request, send_from_directory import get_json from dotenv import load_dotenv import os import json from os.path import join, dirname 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') @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 "Updated"