21 lines
558 B
Python
21 lines
558 B
Python
|
|
from fastapi import FastAPI
|
||
|
|
from backend.news_fetcher import fetch_news
|
||
|
|
from backend.recommender import recommend_similar
|
||
|
|
from backend.config import Config
|
||
|
|
|
||
|
|
app = FastAPI()
|
||
|
|
|
||
|
|
@app.get("/fetch-news")
|
||
|
|
async def get_latest_news():
|
||
|
|
all_news = []
|
||
|
|
for feed in Config.RSS_FEEDS:
|
||
|
|
all_news.extend(fetch_news(feed))
|
||
|
|
return {"news": all_news}
|
||
|
|
|
||
|
|
|
||
|
|
@app.get("/recommend")
|
||
|
|
async def recommend_news(article_id: str):
|
||
|
|
sample_text = "AI breakthroughs in 2024"
|
||
|
|
similar_ids = recommend_similar(sample_text)
|
||
|
|
return {"similar_articles": similar_ids}
|