From ca667f7896263875c379807d43791d6ac93bca58 Mon Sep 17 00:00:00 2001 From: Vivek Santayana Date: Sat, 20 Aug 2022 16:51:13 +0100 Subject: [PATCH] Create database before first request --- ref-test/app/__init__.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ref-test/app/__init__.py b/ref-test/app/__init__.py index be5f4bf..86f7383 100644 --- a/ref-test/app/__init__.py +++ b/ref-test/app/__init__.py @@ -1,5 +1,5 @@ from .config import Production as Config -from .models import User +from .models import * from .extensions import bootstrap, csrf, db, login_manager, mail from .tools.logs import write @@ -58,5 +58,11 @@ def create_app(): app.register_blueprint(quiz) app.register_blueprint(editor, url_prefix='/admin/editor') app.register_blueprint(view, url_prefix='/admin/view') - + + """Create Database Tables before First Request""" + @app.before_first_request + def _create_database_tables(): + with app.app_context(): + db.create_all() + return app \ No newline at end of file