fix 301/400 responses

This commit is contained in:
bretello 2024-06-14 20:08:32 +02:00
parent 649624fb25
commit ab83fcef30
Signed by: brethil
GPG Key ID: 876AAC6290170FE7

7
app.py
View File

@ -76,9 +76,7 @@ def upload_file():
save_path = os.path.join("uploads", file.filename)
if os.path.exists(save_path):
response = make_response(make_response("file already exists", 400))
response.headers["Location"] = "/"
response.status_code = 400
return make_response("file already exists", 400)
try:
file.save(save_path)
@ -91,9 +89,8 @@ def upload_file():
thread.start()
print(f"thread started for {file.filename=}")
response = make_response(make_response("file uploaded succesfully", 301))
response = make_response("file uploaded succesfully", 301)
response.headers["Location"] = "/"
response.status_code = 301
return response