Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,38 +1,37 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
-
import requests
|
| 3 |
-
|
| 4 |
-
# URL
|
| 5 |
-
API_URL = "
|
| 6 |
-
|
| 7 |
-
# Streamlit
|
| 8 |
-
st.title("News
|
| 9 |
-
|
| 10 |
-
company_name = st.text_input("Enter
|
| 11 |
-
|
| 12 |
-
if st.button(
|
| 13 |
-
if company_name:
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
st.write(f"
|
| 22 |
-
st.write(
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
st.write(
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
st.warning("Please enter a company name.")
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import requests
|
| 3 |
+
|
| 4 |
+
# API URL for the Hugging Face Space
|
| 5 |
+
API_URL = "https://company-news-analyzer.hf.space/get_news_and_sentiment"
|
| 6 |
+
|
| 7 |
+
# Streamlit UI
|
| 8 |
+
st.title("Company News Analyzer")
|
| 9 |
+
|
| 10 |
+
company_name = st.text_input("Enter company name:")
|
| 11 |
+
|
| 12 |
+
if st.button("Analyze"):
|
| 13 |
+
if company_name:
|
| 14 |
+
# Send a POST request to the FastAPI backend
|
| 15 |
+
response = requests.post(API_URL, json={"company_name": company_name})
|
| 16 |
+
|
| 17 |
+
if response.status_code == 200:
|
| 18 |
+
data = response.json()
|
| 19 |
+
|
| 20 |
+
# Display results
|
| 21 |
+
st.write(f"Company: {data['Company']}")
|
| 22 |
+
st.write("Articles:")
|
| 23 |
+
for article in data['Articles']:
|
| 24 |
+
st.write(f"Title: {article['Title']}")
|
| 25 |
+
st.write(f"Summary: {article['Summary']}")
|
| 26 |
+
st.write(f"Sentiment: {article['Sentiment']}")
|
| 27 |
+
|
| 28 |
+
# Display comparative sentiment analysis
|
| 29 |
+
st.write("Comparative Sentiment Analysis:")
|
| 30 |
+
st.write(data['Comparative Sentiment Score'])
|
| 31 |
+
|
| 32 |
+
# Play the audio file
|
| 33 |
+
st.audio(data['Audio'], format='audio/mp3')
|
| 34 |
+
else:
|
| 35 |
+
st.error("Failed to fetch data. Please try again.")
|
| 36 |
+
else:
|
| 37 |
+
st.error("Please enter a company name.")
|
|
|