darshankr commited on
Commit
83b59a9
·
verified ·
1 Parent(s): 46683f9

Update run.py

Browse files
Files changed (1) hide show
  1. run.py +14 -7
run.py CHANGED
@@ -1,19 +1,26 @@
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__":
 
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__":