refrence: https://stackoverflow.com/questions/49089584/sqlachemy-no-application-found-either-work-inside-a-view-function-or-push
key point:
app = Flask(__name__) app.config.from_object(config) with app.app_context(): db.init_app(app) ma.init_app(app) db.create_all()