Files
live-campus-mcs-p-2027.2/Semaine_08/mediawatch/adapters/inbound/watch_controller.py
T
gauvainboiche 3315cb2336 feat: Semaine 8
2026-05-11 09:25:19 +02:00

24 lines
763 B
Python

from fastapi import FastAPI
from application.usecases.run_watch_cycle import RunWatchCycleUsecase
from adapters.outbound.rss_feed_adapter import RssFeedAdapter
from adapters.outbound.cli_notifier import CliNotifierAdapter
from domain.matcher import MatchingService
app = FastAPI()
rss_adapter = RssFeedAdapter("https://www.lemonde.fr/rss/une.xml")
notifier = CliNotifierAdapter()
matcher = MatchingService()
usecase = RunWatchCycleUsecase(rss_adapter, notifier, matcher)
@app.get("/rss/{keyword}")
def run_watch_by_http(keyword: str):
result = usecase.execute(keywords=[keyword])
return {
"status": "success",
"keyword_searched": keyword,
"articles_processed": result.processed,
"alerts_sent": result.alerts_sent
}