fix run webapp

This commit is contained in:
ALIHAN DIKEL
2025-03-10 15:37:21 +03:00
parent 6df7c2e9f5
commit 5fb355f806

View File

@@ -1,23 +1,22 @@
import os
import subprocess
from dotenv import load_dotenv
import uvicorn
load_dotenv("env")
# Get variables with defaults
PORT = os.getenv("PORT", "9999")
HOST = os.getenv("HOST", "0.0.0.0")
PORT = int(os.getenv("PORT", "9999"))
RELOAD = os.getenv("RELOAD", "True").lower() == "true"
# Build the command
cmd = [
"uvicorn",
"main:app",
"--host 0.0.0.0",
"--port", PORT
]
def main():
uvicorn.run(
"main:app",
host=HOST,
port=PORT,
reload=RELOAD
)
if RELOAD:
cmd.append("--reload")
subprocess.run(cmd)
if __name__ == "__main__":
main()