aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcbdev <cb@cbcdn.com>2022-04-24 12:26:59 +0200
committercbdev <cb@cbcdn.com>2022-04-24 12:26:59 +0200
commit43c8e2d23a37153591fb34a69fe40caec4ac50b5 (patch)
tree06b02dc2c9f1f29ca88609dca5228f61907c1944
parentf8b3f9d025293173feff2d95077091969adc6158 (diff)
downloadcargohold-43c8e2d23a37153591fb34a69fe40caec4ac50b5.tar.gz
cargohold-43c8e2d23a37153591fb34a69fe40caec4ac50b5.tar.bz2
cargohold-43c8e2d23a37153591fb34a69fe40caec4ac50b5.zip
Simplify redirect calls
-rw-r--r--README.md2
-rw-r--r--backend/main.py8
2 files changed, 5 insertions, 5 deletions
diff --git a/README.md b/README.md
index 9cbd7d1..30588ac 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,7 @@ that lets them download or view the files you want them to have.
* Set the directory's owner to the user you want uwsgi to run the application under
* Edit `backend/config.py` to match your setup
* Edit `configs/nginx.config` to match your setup
- * Note that the `client_max_body_size` will limit the maximum size of a single uploaded file
+ * Note that the `client_max_body_size` directive will limit the maximum size of a single uploaded file
* Install `configs/nginx.config` to `/etc/nginx/sites-enabled`
* Edit `configs/uwsgi.ini` to match your setup
* Note that the `limit-post` option will limit the maximum size of a single uploaded file
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)