from flask import Flask import SETTINGS import routes import re app = Flask(SETTINGS.FLASK_NAME) @app.route('/', defaults={'route': '/'}) # catch HTTP / and set route to "" @app.route("/") # catch everything else and set route to the path def route(route: str): if not route.endswith("/"): route += "/" for r in routes.ROUTES: if match := re.match(r, route): return routes.ROUTES[r](match) # call the handler for the function return "

404 Not found!

", 404 # if nothing matches return 404 Not Found if __name__ == "__main__": app.run(SETTINGS.HTTP_HOST, SETTINGS.HTTP_PORT)