Create database before first request

This commit is contained in:
Vivek Santayana 2022-08-20 16:51:13 +01:00
parent 0cc00ef911
commit ca667f7896

View File

@ -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