Remove the use of before_first_request

This commit is contained in:
Grey Li
2023-11-16 21:08:57 +08:00
parent f959951185
commit 42d859534a
2 changed files with 9 additions and 11 deletions
+4 -5
View File
@@ -28,11 +28,6 @@ class ExampleModel(db.Model):
value = db.Column(db.String(100), primary_key=True)
@app.before_first_request
def setup():
db.create_all()
@app.route('/')
def index():
app.logger.info("Hello there")
@@ -45,3 +40,7 @@ def redirect_example():
response = redirect(url_for('index'))
response.set_cookie('test_cookie', '1')
return response
with app.app_context():
db.create_all()