37 lines
830 B
Python
Executable File
37 lines
830 B
Python
Executable File
#!/usr/bin/env python
|
|
|
|
import os
|
|
import sys
|
|
from dotenv import load_dotenv
|
|
import uvicorn
|
|
|
|
# Load environment variables from .env file
|
|
load_dotenv("env")
|
|
|
|
|
|
def main():
|
|
# Set working directory to src (the crucial part)
|
|
src_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "src")
|
|
os.chdir(src_dir)
|
|
|
|
# Add src directory to Python path
|
|
if src_dir not in sys.path:
|
|
sys.path.insert(0, src_dir)
|
|
|
|
# Get variables with defaults
|
|
host = os.getenv("HOST", "0.0.0.0")
|
|
port = int(os.getenv("PORT", "9999"))
|
|
reload = os.getenv("RELOAD", "True").lower() == "true"
|
|
|
|
# Run server
|
|
uvicorn.run(
|
|
"main:app", # Now main.py will be found in src directory
|
|
host=host,
|
|
port=port,
|
|
reload=reload
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|