pratham0011 commited on
Commit
a49bd26
·
verified ·
1 Parent(s): 81265a7

Update run_app.py

Browse files
Files changed (1) hide show
  1. run_app.py +11 -8
run_app.py CHANGED
@@ -1,11 +1,14 @@
 
1
  import subprocess
2
 
3
- # Start Streamlit
4
- streamlit_process = subprocess.Popen(["streamlit", "run", "streamlit_app.py"])
5
 
6
- # Start Uvicorn
7
- uvicorn_process = subprocess.Popen(["uvicorn", "main:app"])
8
-
9
- # Wait for the processes to finish
10
- streamlit_process.wait()
11
- uvicorn_process.wait()
 
 
 
1
+ import os
2
  import subprocess
3
 
4
+ # Determine which app to run based on an environment variable
5
+ app_type = os.environ.get("APP_TYPE", "streamlit").lower()
6
 
7
+ if app_type == "streamlit":
8
+ # Start Streamlit
9
+ subprocess.run(["streamlit", "run", "streamlit_app.py"])
10
+ elif app_type == "fastapi":
11
+ # Start Uvicorn (FastAPI)
12
+ subprocess.run(["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"])
13
+ else:
14
+ print(f"Unknown APP_TYPE: {app_type}")