Пример #1
0
if 'JORMUNGANDR_CONFIG_FILE' in os.environ:
    app.config.from_envvar('JORMUNGANDR_CONFIG_FILE')

app.request_class = NavitiaRequest
CORS(app, vary_headers=True, allow_credentials=True, send_wildcard=False,
        headers=['Access-Control-Request-Headers', 'Authorization'])
app.config['CORS_HEADERS'] = 'Content-Type'

if 'LOGGER' in app.config:
    logging.config.dictConfig(app.config['LOGGER'])
else:  # Default is std out
    handler = logging.StreamHandler(stream=sys.stdout)
    app.logger.addHandler(handler)
    app.logger.setLevel('INFO')

app.wsgi_app = ReverseProxied(app.wsgi_app)
got_request_exception.connect(log_exception, app)

#we want the old behavior for reqparse
compat.patch_reqparse()

rest_api = Api(app, catch_all_404s=True, serve_challenge_on_401=True)

from navitiacommon.models import db
db.init_app(app)
cache = Cache(app, config=app.config['CACHE_CONFIGURATION'])

if app.config['AUTOCOMPLETE'] is not None:
    global_autocomplete = utils.create_object(app.config['AUTOCOMPLETE']['class_path'],
                                              **app.config['AUTOCOMPLETE']['kwargs'])
else:
Пример #2
0
from jormungandr.exceptions import log_exception
from jormungandr.helper import ReverseProxied, NavitiaRequest, NavitiaRule
from jormungandr import compat, utils

app.url_rule_class = NavitiaRule
app.request_class = NavitiaRequest
CORS(
    app,
    vary_headers=True,
    allow_credentials=True,
    send_wildcard=False,
    headers=['Access-Control-Request-Headers', 'Authorization'],
)
app.config[str('CORS_HEADERS')] = 'Content-Type'

app.wsgi_app = ReverseProxied(app.wsgi_app)  # type: ignore
got_request_exception.connect(log_exception, app)

# we want the old behavior for reqparse
compat.patch_reqparse()

rest_api = Api(app, catch_all_404s=True, serve_challenge_on_401=True)

from navitiacommon.models import db

# NOTE: no db request should be made outside of a request context
# Therefore, the db app shouldn't be set here in order not to cause idle_in_transaction deadlock
db.init_app(app)
cache = Cache(app,
              config=app.config[str('CACHE_CONFIGURATION')])  # type: Cache
memory_cache = Cache(