Spaces:
Sleeping
Sleeping
Commit
·
82c7896
1
Parent(s):
34f28df
Fix FastAPI multiple instance issue
Browse files
app.py
CHANGED
@@ -1,9 +1,7 @@
|
|
1 |
import os
|
2 |
-
import threading
|
3 |
import time
|
4 |
import requests
|
5 |
import streamlit as st
|
6 |
-
import uvicorn
|
7 |
from fastapi import FastAPI
|
8 |
from utils import process_news
|
9 |
|
@@ -11,7 +9,6 @@ import spacy
|
|
11 |
try:
|
12 |
spacy.load("en_core_web_sm")
|
13 |
except OSError:
|
14 |
-
import os
|
15 |
os.system("python -m spacy download en_core_web_sm")
|
16 |
|
17 |
# FastAPI app setup
|
@@ -25,15 +22,8 @@ def read_root():
|
|
25 |
def get_news(company_name: str):
|
26 |
return process_news(company_name)
|
27 |
|
28 |
-
# Function to run FastAPI in a separate thread
|
29 |
-
def run_fastapi():
|
30 |
-
uvicorn.run(api, host="0.0.0.0", port=8000)
|
31 |
-
|
32 |
-
# Start FastAPI in a separate thread
|
33 |
-
threading.Thread(target=run_fastapi, daemon=True).start()
|
34 |
-
|
35 |
# Streamlit app setup
|
36 |
-
API_URL = "http://
|
37 |
|
38 |
st.title("News Summarization and Hindi TTS Application")
|
39 |
company = st.text_input("Enter Company Name", "")
|
|
|
1 |
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 |
|
|
|
9 |
try:
|
10 |
spacy.load("en_core_web_sm")
|
11 |
except OSError:
|
|
|
12 |
os.system("python -m spacy download en_core_web_sm")
|
13 |
|
14 |
# FastAPI app setup
|
|
|
22 |
def get_news(company_name: str):
|
23 |
return process_news(company_name)
|
24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
# Streamlit app setup
|
26 |
+
API_URL = "http://0.0.0.0:8000" # FastAPI runs in the same environment
|
27 |
|
28 |
st.title("News Summarization and Hindi TTS Application")
|
29 |
company = st.text_input("Enter Company Name", "")
|