Spaces:
Runtime error
Runtime error
Update run.py
Browse files
run.py
CHANGED
@@ -1,19 +1,26 @@
|
|
1 |
# run.py
|
2 |
import subprocess
|
3 |
import sys
|
|
|
4 |
|
5 |
def main():
|
6 |
-
# Start
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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__":
|
|
|
1 |
# run.py
|
2 |
import subprocess
|
3 |
import sys
|
4 |
+
import os
|
5 |
|
6 |
def main():
|
7 |
+
# Start Streamlit server only
|
8 |
+
port = int(os.environ.get("PORT", 7860)) # Hugging Face Spaces uses port 7860
|
9 |
+
streamlit_process = subprocess.Popen([
|
10 |
+
sys.executable,
|
11 |
+
"-m",
|
12 |
+
"streamlit",
|
13 |
+
"run",
|
14 |
+
"app.py",
|
15 |
+
"--server.port",
|
16 |
+
str(port),
|
17 |
+
"--server.address",
|
18 |
+
"0.0.0.0"
|
19 |
+
])
|
20 |
|
21 |
try:
|
|
|
22 |
streamlit_process.wait()
|
23 |
except KeyboardInterrupt:
|
|
|
24 |
streamlit_process.terminate()
|
25 |
|
26 |
if __name__ == "__main__":
|