23 lines
770 B
Python
23 lines
770 B
Python
import subprocess
|
|
import sys
|
|
import os
|
|
|
|
# Activate venv if not already active
|
|
def activate_venv():
|
|
venv_path = os.path.join(os.path.dirname(__file__), '.venv', 'bin', 'activate_this.py')
|
|
if os.path.exists(venv_path):
|
|
with open(venv_path) as f:
|
|
exec(f.read(), {'__file__': venv_path})
|
|
|
|
if __name__ == "__main__":
|
|
# Optionally activate venv (works on Linux/macOS)
|
|
venv_python = os.path.join(os.path.dirname(__file__), '.venv', 'bin', 'python')
|
|
if os.path.exists(venv_python):
|
|
python_exec = venv_python
|
|
else:
|
|
python_exec = sys.executable
|
|
|
|
# Launch the FastAPI app with uvicorn
|
|
subprocess.run([
|
|
python_exec, '-m', 'uvicorn', 'app.main:app', '--host', '0.0.0.0', '--port', '8000', '--reload'
|
|
])
|