Spaces:
Sleeping
Sleeping
Commit
·
285e5a3
1
Parent(s):
82c7896
Fix FastAPI startup issue
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@ import os
|
|
2 |
import time
|
3 |
import requests
|
4 |
import streamlit as st
|
|
|
5 |
from fastapi import FastAPI
|
6 |
from utils import process_news
|
7 |
|
@@ -23,7 +24,7 @@ def get_news(company_name: str):
|
|
23 |
return process_news(company_name)
|
24 |
|
25 |
# Streamlit app setup
|
26 |
-
API_URL = "http://
|
27 |
|
28 |
st.title("News Summarization and Hindi TTS Application")
|
29 |
company = st.text_input("Enter Company Name", "")
|
@@ -72,3 +73,8 @@ if st.button("Fetch News"):
|
|
72 |
st.error("Failed to fetch news from the API. Please try again.")
|
73 |
except requests.exceptions.ConnectionError:
|
74 |
st.error("API is not running yet. Please wait a moment and try again.")
|
|
|
|
|
|
|
|
|
|
|
|
2 |
import time
|
3 |
import requests
|
4 |
import streamlit as st
|
5 |
+
import uvicorn # Add this
|
6 |
from fastapi import FastAPI
|
7 |
from utils import process_news
|
8 |
|
|
|
24 |
return process_news(company_name)
|
25 |
|
26 |
# Streamlit app setup
|
27 |
+
API_URL = "http://127.0.0.1:8000" # Use localhost instead of 0.0.0.0
|
28 |
|
29 |
st.title("News Summarization and Hindi TTS Application")
|
30 |
company = st.text_input("Enter Company Name", "")
|
|
|
73 |
st.error("Failed to fetch news from the API. Please try again.")
|
74 |
except requests.exceptions.ConnectionError:
|
75 |
st.error("API is not running yet. Please wait a moment and try again.")
|
76 |
+
|
77 |
+
# 🛠️ **Start FastAPI Server**
|
78 |
+
if __name__ == "__main__":
|
79 |
+
import threading
|
80 |
+
threading.Thread(target=lambda: uvicorn.run(api, host="127.0.0.1", port=8000), daemon=True).start()
|