Update src/frontend/app.py
Browse files- src/frontend/app.py +12 -0
src/frontend/app.py
CHANGED
@@ -13,6 +13,18 @@ import plotly.graph_objects as go
|
|
13 |
from datetime import datetime
|
14 |
import joblib
|
15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
# Add the project root to the Python path
|
17 |
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..')))
|
18 |
|
|
|
13 |
from datetime import datetime
|
14 |
import joblib
|
15 |
|
16 |
+
def run_api():
|
17 |
+
subprocess.Popen(["python", "-m", "uvicorn", "src.api.main:app", "--host", "0.0.0.0", "--port", "8000"])
|
18 |
+
|
19 |
+
# Only start the server once
|
20 |
+
if "api_started" not in st.session_state:
|
21 |
+
threading.Thread(target=run_api).start()
|
22 |
+
st.session_state.api_started = True
|
23 |
+
st.success("Starting API... please wait a few seconds.")
|
24 |
+
|
25 |
+
# Wait a few seconds for server to start
|
26 |
+
time.sleep(5)
|
27 |
+
|
28 |
# Add the project root to the Python path
|
29 |
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..')))
|
30 |
|