Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -155,21 +155,15 @@ async def query(question_request: QuestionRequest):
|
|
155 |
def run_streamlit():
|
156 |
subprocess.Popen(["streamlit", "run", "frontend.py"])
|
157 |
|
158 |
-
# Define a FastAPI endpoint to serve the Streamlit app
|
159 |
@app.get("/")
|
160 |
-
async def serve_streamlit():
|
161 |
# Start the Streamlit app in a background task
|
162 |
background_tasks.add_task(run_streamlit)
|
163 |
-
|
164 |
# Stream the output of the Streamlit app
|
165 |
streamlit_output = subprocess.Popen(["streamlit", "stream", "frontend.py", "--server.port", "8501"], stdout=subprocess.PIPE)
|
166 |
return StreamingResponse(streamlit_output.stdout, media_type="text/plain")
|
167 |
|
168 |
-
# Define a FastAPI endpoint to stop the Streamlit app
|
169 |
-
@app.get("/stop")
|
170 |
-
async def stop_streamlit():
|
171 |
-
subprocess.run(["pkill", "-f", "streamlit"])
|
172 |
-
|
173 |
|
174 |
#if __name__ == '__main__':
|
175 |
#uvicorn.run(app, host='0.0.0.0', port=7860)
|
|
|
155 |
def run_streamlit():
|
156 |
subprocess.Popen(["streamlit", "run", "frontend.py"])
|
157 |
|
|
|
158 |
@app.get("/")
|
159 |
+
async def serve_streamlit(background_tasks: BackgroundTasks):
|
160 |
# Start the Streamlit app in a background task
|
161 |
background_tasks.add_task(run_streamlit)
|
162 |
+
|
163 |
# Stream the output of the Streamlit app
|
164 |
streamlit_output = subprocess.Popen(["streamlit", "stream", "frontend.py", "--server.port", "8501"], stdout=subprocess.PIPE)
|
165 |
return StreamingResponse(streamlit_output.stdout, media_type="text/plain")
|
166 |
|
|
|
|
|
|
|
|
|
|
|
167 |
|
168 |
#if __name__ == '__main__':
|
169 |
#uvicorn.run(app, host='0.0.0.0', port=7860)
|