-
Notifications
You must be signed in to change notification settings - Fork 2
/
run.py
50 lines (34 loc) · 1.23 KB
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from datetime import datetime
from app.env import DB, MA
from flask import Flask
from werkzeug.middleware.proxy_fix import ProxyFix
from urllib.parse import urlsplit
app_globals = {}
def init_app():
if app_globals.get("app", False):
app = app_globals["app"]
else:
app = Flask(__name__)
app.config.from_object("config")
api_uri = urlsplit(app.config["URL_APPLICATION"])
app.config["APPLICATION_ROOT"] = api_uri.path
app.config["PREFERRED_URL_SCHEME"] = api_uri.scheme
# app.wsgi_app = ReverseProxied(app.wsgi_app, script_name=app.config['URL_APPLICATION'])
app.wsgi_app = ProxyFix(app.wsgi_app, x_host=1)
@app.context_processor
def inject_year():
return {"current_year": datetime.now().year}
with app.app_context():
DB.init_app(app)
MA.init_app(app)
from pypnusershub import routes
app.register_blueprint(routes.routes, url_prefix="/pypn/auth")
from app.views import routes
app.register_blueprint(routes, url_prefix="/")
@app.template_filter("fr_boolean")
def fr_boolean(val):
return "Oui" if val else "Non"
return app
app = init_app()
if __name__ == "__main__":
app.run(debug=True, port=5003)