Spaces:
Sleeping
Sleeping
import subprocess | |
import sys | |
def run_uvicorn(): | |
# Command to run the FastAPI app with uvicorn | |
command = [ | |
"uvicorn", | |
"main:app", | |
"--host", "0.0.0.0", | |
"--port", "7860", | |
"--reload" | |
] | |
# Run the command | |
subprocess.run(command, check=True) | |
if __name__ == "__main__": | |
try: | |
run_uvicorn() | |
except subprocess.CalledProcessError as e: | |
print(f"Error running uvicorn: {e}", file=sys.stderr) | |
sys.exit(1) | |