-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patht11.py
27 lines (22 loc) · 787 Bytes
/
t11.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import os
import subprocess
import time
import streamlit as st
# Function to start FastAPI server if it's not running
def start_fastapi():
try:
# Check if the FastAPI server is already running
import requests
response = requests.get("http://localhost:8000")
if response.status_code == 200:
st.success("FastAPI server is already running.")
return
except:
pass # If request fails, start the server
st.info("Starting FastAPI server...")
# Run FastAPI server in a separate process
subprocess.Popen(["python", "pages/FinRag/main.py"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
# Give the server some time to start
time.sleep(3)
# Start FastAPI automatically
start_fastapi()