-
Notifications
You must be signed in to change notification settings - Fork 23
/
wsgi-classic-api.py
29 lines (22 loc) · 999 Bytes
/
wsgi-classic-api.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
"""Web Server Gateway Interface entry-point for classic API."""
import os
from arxiv.base import logging
from search.factory import create_classic_api_web_app
logger = logging.getLogger(__name__)
__flask_app__ = None
def application(environ, start_response):
"""WSGI application factory."""
for key, value in environ.items():
# In some deployment scenarios (e.g. uWSGI on k8s), uWSGI will pass in
# the hostname as part of the request environ. This will usually just
# be a container ID, which is not helpful for things like building
# URLs. We want to keep ``SERVER_NAME`` explicitly configured, either
# in config.py or via an os.environ var loaded by config.py.
if key == "SERVER_NAME":
continue
if type(value) is str:
os.environ[key] = value
global __flask_app__
if __flask_app__ is None:
__flask_app__ = create_classic_api_web_app()
return __flask_app__(environ, start_response)