From 77afe1dd238c9e698d731f4778199292ed19ed0c Mon Sep 17 00:00:00 2001 From: wcyat Date: Sat, 28 Jan 2023 15:00:50 +0800 Subject: [PATCH] feat: disable upload form idea and some code from https://github.com/hauxir/imgpush/pull/33 --- README.md | 1 + app/app.py | 2 ++ app/settings.py | 1 + example.env | 1 + 4 files changed, 5 insertions(+) diff --git a/README.md b/README.md index ae3d0bf..898d523 100644 --- a/README.md +++ b/README.md @@ -136,6 +136,7 @@ livenessProbe: | GET_REQUIRE_AUTH | "False" | Whether to require authentication for get requests | | DISABLE_RESIZE | "False" | Disable resizing images | | DISABLE_URL_UPLOAD | "False" | Disable uploading using urls | +| DISABLE_UPLOAD_FORM | "False" | Disable upload form | | UPLOAD_ROUTE | "/" | The route for uploading images | | IMAGES_ROOT | "" | The root for images get requests | diff --git a/app/app.py b/app/app.py index 94a10a3..e65d7a4 100644 --- a/app/app.py +++ b/app/app.py @@ -151,6 +151,8 @@ def resize(img, width, height): @app.route("/", methods=["GET"]) def root(): + if settings.DISABLE_UPLOAD_FORM: + return jsonify(error="Not found"), 404 return f"""
diff --git a/app/settings.py b/app/settings.py index 13d6d33..0680156 100644 --- a/app/settings.py +++ b/app/settings.py @@ -21,6 +21,7 @@ GET_REQUIRE_AUTH = False DISABLE_RESIZE = False DISABLE_URL_UPLOAD = False +DISABLE_UPLOAD_FORM = False UPLOAD_ROUTE = "/" IMAGES_ROOT = "" diff --git a/example.env b/example.env index b5960fc..73fcc76 100644 --- a/example.env +++ b/example.env @@ -19,6 +19,7 @@ UPLOAD_REQUIRE_AUTH=False GET_REQUIRE_AUTH=False DISABLE_RESIZE=False DISABLE_URL_UPLOADS=False +DISABLE_UPLOAD_FORM=False UPLOAD_ROUTE="/" IMAGES_ROOT="" VALID_SIZES=[]