-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathserver.py
More file actions
31 lines (21 loc) · 818 Bytes
/
server.py
File metadata and controls
31 lines (21 loc) · 818 Bytes
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
import os
import logging.config
import configparser
from granian.utils.proxies import wrap_wsgi_with_proxy_headers
from kinto import main
def load_application():
ini_path = os.environ.get("KINTO_INI")
if not ini_path:
raise RuntimeError("Environment variable KINTO_INI is not set")
if not os.path.isfile(ini_path):
raise RuntimeError(f"KINTO_INI file not found: {ini_path}")
logging.config.fileConfig(ini_path, disable_existing_loggers=False)
config = configparser.ConfigParser()
config.read(ini_path)
app = main(
config.items("DEFAULT"),
**dict(config.items("app:main")),
)
trusted_hosts = os.getenv("GRANIAN_TRUSTED_HOSTS", "").split(",")
return wrap_wsgi_with_proxy_headers(app, trusted_hosts=trusted_hosts)
app = load_application()