Skip to content

Commit

Permalink
feat: disable upload form
Browse files Browse the repository at this point in the history
idea and some code from hauxir#33
  • Loading branch information
sdip15fa committed Jan 28, 2023
1 parent 7584888 commit 77afe1d
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |

Expand Down
2 changes: 2 additions & 0 deletions app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
<form action="{settings.UPLOAD_ROUTE}" method="post" enctype="multipart/form-data">
<input type="file" name="file" id="file">
Expand Down
1 change: 1 addition & 0 deletions app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
GET_REQUIRE_AUTH = False
DISABLE_RESIZE = False
DISABLE_URL_UPLOAD = False
DISABLE_UPLOAD_FORM = False
UPLOAD_ROUTE = "/"
IMAGES_ROOT = ""

Expand Down
1 change: 1 addition & 0 deletions example.env
Original file line number Diff line number Diff line change
Expand Up @@ -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=[]
Expand Down

0 comments on commit 77afe1d

Please sign in to comment.