Spaces:
Runtime error
Runtime error
Create run.py
Browse files
run.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# run.py
|
2 |
+
import subprocess
|
3 |
+
import sys
|
4 |
+
|
5 |
+
def main():
|
6 |
+
# Start FastAPI server
|
7 |
+
api_process = subprocess.Popen([sys.executable, "-m", "uvicorn", "api:app", "--host", "0.0.0.0", "--port", "8000"])
|
8 |
+
|
9 |
+
# Start Streamlit server
|
10 |
+
streamlit_process = subprocess.Popen([sys.executable, "-m", "streamlit", "run", "app.py"])
|
11 |
+
|
12 |
+
try:
|
13 |
+
api_process.wait()
|
14 |
+
streamlit_process.wait()
|
15 |
+
except KeyboardInterrupt:
|
16 |
+
api_process.terminate()
|
17 |
+
streamlit_process.terminate()
|
18 |
+
|
19 |
+
if __name__ == "__main__":
|
20 |
+
main()
|