32 lines
779 B
Python
Executable File
32 lines
779 B
Python
Executable File
import os
|
|
import sys
|
|
from dotenv import load_dotenv
|
|
import uvicorn
|
|
|
|
# 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", "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():
|
|
"""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__":
|
|
main()
|