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 .config import Production as Config
from .models import User from .models import *
from .extensions import bootstrap, csrf, db, login_manager, mail from .extensions import bootstrap, csrf, db, login_manager, mail
from .tools.logs import write from .tools.logs import write
@ -59,4 +59,10 @@ def create_app():
app.register_blueprint(editor, url_prefix='/admin/editor') app.register_blueprint(editor, url_prefix='/admin/editor')
app.register_blueprint(view, url_prefix='/admin/view') 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 return app