Compare commits
2 Commits
50e5162a52
...
3ebc9fb142
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3ebc9fb142 | ||
|
|
a0e8d8bcb5 |
@@ -1,22 +1,30 @@
|
||||
import os
|
||||
import sys
|
||||
from dotenv import load_dotenv
|
||||
import uvicorn
|
||||
|
||||
|
||||
load_dotenv("env")
|
||||
# Load environment variables from .env file
|
||||
load_dotenv()
|
||||
|
||||
# Get variables with defaults
|
||||
HOST = os.getenv("HOST", "0.0.0.0")
|
||||
PORT = int(os.getenv("PORT", "9999"))
|
||||
PORT = int(os.getenv("PORT", "8000"))
|
||||
RELOAD = os.getenv("RELOAD", "True").lower() == "true"
|
||||
APP_MODULE = os.getenv("APP_MODULE", "main:app")
|
||||
WORKING_DIR = os.getenv("WORKING_DIR", os.getcwd())
|
||||
|
||||
|
||||
def main():
|
||||
uvicorn.run(
|
||||
"main:app",
|
||||
host=HOST,
|
||||
port=PORT,
|
||||
reload=RELOAD
|
||||
)
|
||||
"""Run the uvicorn server directly using the Python API"""
|
||||
# Change to the specified working directory
|
||||
os.chdir(WORKING_DIR)
|
||||
|
||||
# Add the working directory to Python path if needed
|
||||
if WORKING_DIR not in sys.path:
|
||||
sys.path.insert(0, WORKING_DIR)
|
||||
|
||||
uvicorn.run(APP_MODULE, host=HOST, port=PORT, reload=RELOAD)
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user