-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathasgi.py
More file actions
38 lines (27 loc) · 1.04 KB
/
asgi.py
File metadata and controls
38 lines (27 loc) · 1.04 KB
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
"""
ASGI config for core project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/
"""
from __future__ import annotations
import configparser
import os
from django.core.asgi import get_asgi_application
def configure_application() -> None:
"""
Configure settings based on config file and environment variables
"""
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "integreat_cms.core.settings")
# Read config from config file
config = configparser.ConfigParser(interpolation=None)
config.read("/etc/integreat-cms.ini")
for section in config.sections():
for KEY, VALUE in config.items(section):
os.environ.setdefault(f"INTEGREAT_CMS_{KEY.upper()}", VALUE)
# Read config from environment
for key, value in os.environ.items():
if key.startswith("INTEGREAT_CMS_"):
os.environ[key] = value
configure_application()
application = get_asgi_application()