Prince-29's picture
Upload 5 files
f3333e8
raw
history blame contribute delete
438 Bytes
from fastapi import FastAPI
from pydantic import BaseModel
from utils import fetch_news, analyze_sentiment
app = FastAPI()
class NewsRequest(BaseModel):
company: str
@app.post("/get_news/")
def get_news(data: NewsRequest):
news_articles = fetch_news(data.company)
for article in news_articles:
article["sentiment"] = analyze_sentiment(article["summary"])
return {"articles": news_articles}