From beaa61362aed31f229c935a347e382024eee5a90 Mon Sep 17 00:00:00 2001 From: Gareth Coles Date: Mon, 5 Feb 2018 12:22:49 +0000 Subject: Dynamic route loader; proper application structure Also fixed flake8-imports getting the other wrong --- app.py | 35 +++++------------------------------ 1 file changed, 5 insertions(+), 30 deletions(-) (limited to 'app.py') diff --git a/app.py b/app.py index 7d1f3dcf..f3bb9a60 100644 --- a/app.py +++ b/app.py @@ -1,35 +1,10 @@ -#!/usr/bin/env python3 +# coding=utf-8 -import os +from pysite.route_manager import RouteManager -from flask import Flask -from flask import jsonify -from flask import redirect - -app = Flask(__name__) - -app.secret_key = os.environ.get("WEBPAGE_SECRET_KEY") - - -@app.route("/") -def index(): - return "Coming soon:tm:" - - -@app.route("/invite") -def invite(): - return redirect("http://invite.pythondiscord.com/") - - -@app.route("/healthcheck") -def healthcheck(): - return jsonify({"status": "ok"}) - - -@app.errorhandler(404) -def page_not_found(e): - return "replace me with a template, 404 not found", 404 +manager = RouteManager() +app = manager.app if __name__ == '__main__': - app.run(port=int(os.environ.get("WEBPAGE_PORT")), debug=False) + manager.run() -- cgit v1.2.3