12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- # -*- 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_events = requests.get("https://api.boudicca.events/event").json()
- return render_template('events.html', events=boudicca_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
|