Initial project import
This commit is contained in:
44
scripts/08_app_utils.py
Normal file
44
scripts/08_app_utils.py
Normal file
@@ -0,0 +1,44 @@
|
||||
"""Funcoes auxiliares da interface web local.
|
||||
|
||||
Entradas:
|
||||
Estrutura padrao do projeto e web_app.py.
|
||||
|
||||
Saidas:
|
||||
Inicializacao local da interface em http://127.0.0.1:8050 quando chamado
|
||||
diretamente.
|
||||
|
||||
Papel no pipeline:
|
||||
Facilita acesso ao app Python com interface web local.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import importlib
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
config = importlib.import_module("01_config")
|
||||
io_utils = importlib.import_module("02_io_utils")
|
||||
|
||||
|
||||
def comando_python_app() -> list[str]:
|
||||
"""Retorna comando portavel para iniciar a interface web local."""
|
||||
pythonw = config.PROJECT_ROOT / ".venv" / "Scripts" / "pythonw.exe"
|
||||
python = config.PROJECT_ROOT / ".venv" / "Scripts" / "python.exe"
|
||||
exe = pythonw if pythonw.exists() else python if python.exists() else sys.executable
|
||||
return [str(exe), str(config.PROJECT_ROOT / "web_app.py")]
|
||||
|
||||
|
||||
def abrir_app() -> None:
|
||||
"""Inicia o app em segundo plano sem janela de console quando possivel."""
|
||||
io_utils.configurar_ambiente()
|
||||
subprocess.Popen(comando_python_app(), cwd=config.PROJECT_ROOT)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
abrir_app()
|
||||
print("Interface web local iniciada em http://127.0.0.1:8050")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user