helloflask / bootstrap-flask

Bootstrap 4 & 5 helper for your Flask projects.
https://bootstrap-flask.readthedocs.io
Other
1.1k stars 189 forks source link

replace deprecated decorator before_first_request #320

Closed PanderMusubi closed 9 months ago

greyli commented 9 months ago

This change will cause these codes to be called multiple times since the debug mode is enabled, but it's OK since it's just an example application.

PanderMusubi commented 9 months ago

What would be a way to improve this? And why only in debug mode? Especially beginners use our examples as a starting point and we don't want to give then the wrong idea. For now, the examples work again but I would like to improve on this in the future.

greyli commented 8 months ago

What would be a way to improve this?

Creating a separate command function to create the database will be better.

And why only in debug mode?

The reloader will reload the app when the code changes, and then the db.create_all will be called again.

Adding a CLI function will require the user to call a separate command before running the application. I'm Okay with the current setup.

PanderMusubi commented 8 months ago

Was this also the case with the before_frist_request implementation? Asking for also other implementations that are not this demo.

greyli commented 8 months ago

No. That's a callback.