diff options
author | cbdev <cb@cbcdn.com> | 2022-04-24 12:26:59 +0200 |
---|---|---|
committer | cbdev <cb@cbcdn.com> | 2022-04-24 12:26:59 +0200 |
commit | 43c8e2d23a37153591fb34a69fe40caec4ac50b5 (patch) | |
tree | 06b02dc2c9f1f29ca88609dca5228f61907c1944 /backend | |
parent | f8b3f9d025293173feff2d95077091969adc6158 (diff) | |
download | cargohold-43c8e2d23a37153591fb34a69fe40caec4ac50b5.tar.gz cargohold-43c8e2d23a37153591fb34a69fe40caec4ac50b5.tar.bz2 cargohold-43c8e2d23a37153591fb34a69fe40caec4ac50b5.zip |
Simplify redirect calls
Diffstat (limited to 'backend')
-rw-r--r-- | backend/main.py | 8 |
1 files changed, 4 insertions, 4 deletions
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) |