Spaces:
Sleeping
Sleeping
Download launch.py from uvpatel7271/final-python-env: direct link, hf CLI and curl.
- Browser
- Download file 853 Bytes
-
https://huggingface.co/spaces/uvpatel7271/final-python-env/resolve/main/launch.py
- Command line
-
hf download hf://spaces/uvpatel7271/final-python-env/launch.py
-
curl -L -o launch.py https://huggingface.co/spaces/uvpatel7271/final-python-env/resolve/main/launch.py
853 Bytes
| """Launch the FastAPI backend and Streamlit UI in one Docker container.""" | |
| from __future__ import annotations | |
| import subprocess | |
| import sys | |
| def main() -> int: | |
| """Start the API backend in the background and keep Streamlit in the foreground.""" | |
| api_process = subprocess.Popen( | |
| ["uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "8001"], | |
| ) | |
| try: | |
| return subprocess.call( | |
| [ | |
| "streamlit", | |
| "run", | |
| "app/streamlit_app.py", | |
| "--server.port", | |
| "8000", | |
| "--server.address", | |
| "0.0.0.0", | |
| "--server.headless", | |
| "true", | |
| ] | |
| ) | |
| finally: | |
| api_process.terminate() | |
| api_process.wait(timeout=10) | |
| if __name__ == "__main__": | |
| sys.exit(main()) | |