# -*- coding: utf-8 -*- """ Created on Sat Apr 22 17:07:13 2022 @author: Hammerle """ import json import requests from flask import Flask, render_template # FOLDER = "src/" # docker FOLDER = "" # local app = Flask(__name__) app.config["TEMPLATES_AUTO_RELOAD"] = True with open(f"{FOLDER}secret_key", "rb") as secretKeyFile: app.secret_key = secretKeyFile.read() @app.route("/", methods=["GET"]) def index(): return render_template("index.html") @app.route("/karte", methods=["GET"]) def map_(): marker_groups = read_database("map") return render_template("map.html", marker_groups=marker_groups) @app.route("/schritte", methods=["GET"]) def steps(): steps = read_database("steps") return render_template("steps.html", steps=steps) @app.route("/events", methods=["GET"]) def events(): boudicca_req = requests.get("https://api.boudicca.events/events") events = [] if boudicca_req.status_code == 200: events = boudicca_req.json() return render_template('events.html', events=events) @app.route("/mitgestaltung", methods=["GET"]) def contribute(): return render_template("contribute.html") def read_database(name): with open(f"{FOLDER}database_{name}.json") as file: db_data = json.load(file) return db_data if __name__ == "__main__": app.run() # localhost # app.run(host="0.0.0.0") # in network