diff --git a/backend/app/__init__.py b/backend/app/__init__.py index 900e2816c4..1608020af3 100644 --- a/backend/app/__init__.py +++ b/backend/app/__init__.py @@ -31,7 +31,7 @@ def create_app(config=None): template_folder=f"{config.PROJECT_ROOT}/templates", static_folder=f"{config.PROJECT_ROOT}/static", ) - app.teardown_request(teardown_session) + app.config.from_object(config) register_extensions(app) @@ -58,7 +58,3 @@ def register_extensions(app): def register_errorhandlers(app): handler = ExceptionHandler() app.register_error_handler(Exception, handler) - - -def teardown_session(*args, **kwargs): - db.session.remove() diff --git a/backend/startup.py b/backend/startup.py index 33aa0bd56a..a8a5ba2348 100644 --- a/backend/startup.py +++ b/backend/startup.py @@ -11,6 +11,7 @@ # we prevent this monkeypatching import os +from app.extensions import db os.environ["EVENTLET_NO_GREENDNS"] = "yes" import eventlet # noqa @@ -20,5 +21,11 @@ app = create_app() + +@app.teardown_request +def teardown_session(*args, **kwargs): + db.session.remove() + + if __name__ == "__main__": eventlet.wsgi.server(eventlet.listen(("0.0.0.0", 5000)), app, log=app.logger)