-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
30 lines (22 loc) · 885 Bytes
/
main.py
File metadata and controls
30 lines (22 loc) · 885 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import logging
from fastapi import FastAPI
from fastapi.responses import Response
from src.feed_generator import create_feed
from src.utils.parsing import parse_atom_feed, parse_feed_uri
logger = logging.getLogger(__name__)
logging.basicConfig(
level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
)
app = FastAPI(title="GitHub Feed Generator")
@app.get("/generate_rss")
async def generate_rss(source: str, author: str = "", branch: str = "main"):
feed_url = parse_feed_uri(source, author, branch)
atom_feed = parse_atom_feed(feed_url)
try:
rss_feed = create_feed(atom_feed)
return Response(rss_feed, media_type="application/rss+xml")
except Exception as e:
logger.error(
f"Error generating RSS feed: {str(e)}", exc_info=True, stack_info=True
)
return f"Error: {str(e)}", 500