Spaces:
Sleeping
Sleeping
| """ | |
| Hugging Face Spaces startup script for DeepGuard AI | |
| This script starts both FastAPI backend and Streamlit frontend | |
| """ | |
| import subprocess | |
| import time | |
| import threading | |
| import os | |
| def start_fastapi(): | |
| """Start FastAPI server in background""" | |
| print("Starting FastAPI server...") | |
| subprocess.run(["python", "app/main.py"]) | |
| def start_streamlit(): | |
| """Start Streamlit app""" | |
| print("Waiting for FastAPI server to start...") | |
| time.sleep(10) # Give FastAPI time to start | |
| print("Starting Streamlit app...") | |
| subprocess.run([ | |
| "streamlit", "run", "src/streamlit_app.py", | |
| "--server.port=7860", | |
| "--server.address=0.0.0.0" | |
| ]) | |
| if __name__ == "__main__": | |
| # Start FastAPI in background thread | |
| fastapi_thread = threading.Thread(target=start_fastapi, daemon=True) | |
| fastapi_thread.start() | |
| # Start Streamlit in main thread | |
| start_streamlit() | |