Skip to content

Commit

Permalink
Automatizada creación de las tablas de la BD al iniciar la aplicación
Browse files Browse the repository at this point in the history
  • Loading branch information
danielfeitopin committed Feb 24, 2023
1 parent a523903 commit 6d720f4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/.flaskenv
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
FLASK_APP=flaskapp
FLASK_DEBUG=True
FLASK_RUN_PORT=8080
FLASK_RUN_PORT=8080
FLASK_DB_INIT=True
5 changes: 4 additions & 1 deletion src/flaskapp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,7 @@ def create_app(test_config: dict = None) -> Flask:
from .utils import db_cli
app.cli.add_command(db_cli)

return app
with app.app_context():
if os.getenv('FLASK_DB_INIT') == 'True':
db.create_all()
return app

0 comments on commit 6d720f4

Please sign in to comment.