From 64bfdc512373e198a385d7172a3802c4567f2fd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Hells=C3=A9n?= Date: Sat, 10 Dec 2022 23:45:50 +0100 Subject: [PATCH] Redirect to newly created feed instead of giving JSON back --- discord_rss_bot/main.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/discord_rss_bot/main.py b/discord_rss_bot/main.py index d4c0d45..e4ad520 100644 --- a/discord_rss_bot/main.py +++ b/discord_rss_bot/main.py @@ -33,8 +33,8 @@ from typing import Any, Iterable import uvicorn from apscheduler.schedulers.background import BackgroundScheduler -from fastapi import FastAPI, Form, HTTPException, Request -from fastapi.responses import FileResponse, HTMLResponse +from fastapi import FastAPI, Form, Request +from fastapi.responses import FileResponse, HTMLResponse, RedirectResponse from fastapi.staticfiles import StaticFiles from fastapi.templating import Jinja2Templates from reader import Entry, EntryCounts, Feed, FeedCounts @@ -66,7 +66,7 @@ templates.env.filters["encode_url"] = encode_url @app.post("/add") -async def create_feed(feed_url: str = Form(), webhook_dropdown: str = Form()) -> HTTPException | dict[str, str]: +async def create_feed(feed_url: str = Form(), webhook_dropdown: str = Form()): """ Add a feed to the database. @@ -94,8 +94,7 @@ async def create_feed(feed_url: str = Form(), webhook_dropdown: str = Form()) -> reader.update_search() - # TODO: Go to the feed page. - return {"feed_url": str(feed_url), "status": "added"} + return RedirectResponse(url=f"/feed/?feed_url={feed_url}", status_code=303) def create_list_of_webhooks() -> list[dict[str, str]]: