From b5c3edf871228b1303c9a6fe71bcda80174f8df8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Hells=C3=A9n?= Date: Tue, 6 Dec 2022 09:39:32 +0100 Subject: [PATCH] Convert /feed to GET instead of POST --- discord_rss_bot/main.py | 8 +++++--- discord_rss_bot/templates/index.html | 6 +----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/discord_rss_bot/main.py b/discord_rss_bot/main.py index 088de75..851bca6 100644 --- a/discord_rss_bot/main.py +++ b/discord_rss_bot/main.py @@ -139,8 +139,8 @@ def get_add(request: Request): return templates.TemplateResponse("add.html", context) -@app.post("/feed", response_class=HTMLResponse) -async def get_feed(request: Request, feed_url: str = Form()): +@app.get("/feed/{feed_url:path}", response_class=HTMLResponse) +async def get_feed(feed_url: str, request: Request): """ Get a feed by URL. @@ -151,7 +151,9 @@ async def get_feed(request: Request, feed_url: str = Form()): Returns: HTMLResponse: The HTML response. """ - logger.info(f"Get feed: {feed_url}") + # Convert the URL to a valid URL. + logger.info(f"Got feed: {feed_url}") + feed = reader.get_feed(feed_url) return templates.TemplateResponse("feed.html", {"request": request, "feed": feed}) diff --git a/discord_rss_bot/templates/index.html b/discord_rss_bot/templates/index.html index c445852..4feac10 100644 --- a/discord_rss_bot/templates/index.html +++ b/discord_rss_bot/templates/index.html @@ -9,11 +9,7 @@ {% if feeds %} {% for feed in feeds %} -
- -
+ {{ feed.url }} {% endfor %} {% else %}

No feeds yet