From 43c8e2d23a37153591fb34a69fe40caec4ac50b5 Mon Sep 17 00:00:00 2001 From: cbdev Date: Sun, 24 Apr 2022 12:26:59 +0200 Subject: Simplify redirect calls --- backend/main.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'backend') diff --git a/backend/main.py b/backend/main.py index 8af66ca..1cf577d 100644 --- a/backend/main.py +++ b/backend/main.py @@ -8,8 +8,8 @@ import mimetypes def playout(filename, content = "text/html"): return ["", [('Content-Type', content if content else "application/octet-stream"), ("X-Accel-Redirect", filename)], None] -def home(): - return ["", [('Content-Type','text/html'), ("Location", config.homepage)], "302 Home"] +def redirect(target): + return ["", [('Content-Type','text/html'), ("Location", target)], "302 Redirect"] def target_filename_internal(session, filename): target = session["path"] + "/" @@ -76,13 +76,13 @@ def route(path, env, session, post): session = resolve_alias(path[0]) if not session: - return home() + return redirect(config.homepage) #print(json.dumps(session)) # Redirect if no slash after alias if len(path) == 1: - return ["", [('Content-Type','text/html'), ("Location", path[0] + "/")], "302 Redirect"] + return redirect(path[0] + "/"); if len(path) > 1 and path[1] == "upload": return upload(session, post) -- cgit v1.2.3