From e6057cd5661efb0297b907d634204a8b8f9e7972 Mon Sep 17 00:00:00 2001 From: andersonid Date: Tue, 15 Apr 2025 15:10:21 -0300 Subject: [PATCH] =?UTF-8?q?fix(#11):=20Corrige=20inicializa=C3=A7=C3=A3o?= =?UTF-8?q?=20do=20sistema=20para=20n=C3=A3o=20recriar=20usu=C3=A1rios=20a?= =?UTF-8?q?=20cada=20execu=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 5 ++++- app.py | 19 ++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index a9a5333..9292d78 100644 --- a/Makefile +++ b/Makefile @@ -11,10 +11,13 @@ init-db: clean seed: init-db python seed.py +init: + python app.py --init + run: python app.py -run-with-seed: seed run +run-with-seed: seed init run reset-admin: clean python create_admin.py diff --git a/app.py b/app.py index 64bc675..e50bb1f 100644 --- a/app.py +++ b/app.py @@ -52,6 +52,7 @@ from flask_wtf.csrf import CSRFProtect import json from utils.date_utils import validar_data, converter_data, validar_sequencia_datas, calcular_idade from routes.admin import admin_bp # Importar o blueprint administrativo +import sys load_dotenv() @@ -1713,18 +1714,18 @@ def init_system(): def main(): # Criar a aplicação app = create_app() - - # Inicializar o sistema - init_system() - return app # Criar a aplicação usando a função main app = main() if __name__ == '__main__': - app.run( - host='0.0.0.0', - port=5000, - debug=os.getenv('FLASK_ENV') == 'development' - ) + # Verificar se é para inicializar o sistema + if '--init' in sys.argv: + init_system() + else: + app.run( + host='0.0.0.0', + port=5000, + debug=os.getenv('FLASK_ENV') == 'development' + )