📌  相关文章
📜  烧瓶 未找到应用程序.在视图函数中工作或推送应用程序上下文 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:20.325000             🧑  作者: Mango

代码示例1
# This file initializes your application and brings together all of the various components.

# TL;DR: db.create_all(app=app)

from flask import Flask
from .views import mainRoutes    # This just imports my URL-routes
from .extensions import db        # Creates db in another file

app = Flask(__name__)

app.config.from_pyfile('../settings.py')    # Separate file to configure your app

db.init_app(app)
db.create_all(app=app)            # THIS IS THE CRITICAL SOLUTION

app.register_blueprint(mainRoutes)

from DatabaseTest import views # import down here to prevent circular imports