set filename in output

This commit is contained in:
Michael Grote 2023-04-13 13:51:45 +02:00
parent 089351e77e
commit 0e90cd40ca
2 changed files with 6 additions and 5 deletions

6
app.py
View file

@ -42,7 +42,7 @@ def download_file(filename):
try:
return send_from_directory(app.config['UPLOAD_DIRECTORY'], filename)
except FileNotFoundError:
return jsonify({'error': 'File not found'}), 404
return jsonify({'error': 'File \'{}\' not found'}), 404
@app.route('/delete/<filename>', methods=['DELETE'])
def delete_file(filename):
@ -54,7 +54,7 @@ def delete_file(filename):
file_path = os.path.join(app.config['UPLOAD_DIRECTORY'], filename)
if not os.path.isfile(file_path):
return jsonify({'error': 'File not found'}), 404
return jsonify({'error': 'File \'{}\' not found'}), 404
os.remove(file_path)
return jsonify({'success': 'File \'{}\' successfully deleted'.format(filename)})
@ -93,7 +93,7 @@ if __name__ == '__main__':
# delete
# curl -X DELETE -H "token: myuploadtoken" http://docker10.grote.lan:5040/delete/hallowelt
# list
# curl -H "token: myauthtoken" http://docker10.grote.lan:5040/list
# curl -H "token: myuploadtoken" http://docker10.grote.lan:5040/list

View file

@ -12,5 +12,6 @@ services:
MAX_CONTENT_LENGTH: 10 # in MB; default 5MB
UPLOAD_DIRECTORY: /uploads # where to store the uploaded files; should be mapped to a docker volume; default "/uploads"
AUTH_TOKEN: myuploadtoken # token used for authenticating
volumes:
uploads:
volumes:
uploads: