forked from whiskyechobravo/kerkoapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wsgi.py
38 lines (28 loc) · 921 Bytes
/
wsgi.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
import errno
import sys
from flask import redirect, url_for
from kerko.config_helpers import config_get
from kerkoapp import create_app
try:
app = create_app()
except RuntimeError as e:
print(e, file=sys.stderr) # noqa: T201
sys.exit(errno.EINTR) # This should make the WSGI server exit as well.
@app.route("/")
def home():
return redirect(url_for("kerko.search"))
try:
proxy_fix_config = config_get(app.config, "kerkoapp.proxy_fix")
except KeyError:
pass
else:
if proxy_fix_config.get("enabled"):
from werkzeug.middleware.proxy_fix import ProxyFix
app.wsgi_app = ProxyFix(
app.wsgi_app,
**{kwarg: value for kwarg, value in proxy_fix_config.items() if kwarg != "enabled"},
)
@app.shell_context_processor
def make_shell_context():
"""Return context dict for a shell session, giving access to variables."""
return {"app": app}