mirror of
https://gitea.augustin64.fr/piair/MsRewards-Reborn.git
synced 2025-08-10 07:16:37 +02:00
still about the file backup
This commit is contained in:
22
Flask/app.py
22
Flask/app.py
@ -412,8 +412,28 @@ def download(filename):
|
||||
print("file send !")
|
||||
return send_from_directory(directory='/app/MsRewards-Reborn/user_data/', path=filename, as_attachment=True)
|
||||
|
||||
ALLOWED_EXTENSIONS = [".json"]
|
||||
def allowed_file(filename):
|
||||
return '.' in filename and \
|
||||
filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
|
||||
|
||||
|
||||
@app.route('/upload_file/', methods=['POST'])
|
||||
@login_required
|
||||
def upload_file():
|
||||
# check if the post request has the file part
|
||||
if 'file' not in request.files:
|
||||
print('No file part')
|
||||
return redirect(request.url)
|
||||
file = request.files['file']
|
||||
# If the user does not select a file, the browser submits an
|
||||
# empty file without a filename.
|
||||
if file.filename == '':
|
||||
print('No selected file')
|
||||
return redirect(request.url)
|
||||
if file and allowed_file(file.filename):
|
||||
filename = secure_filename(file.filename)
|
||||
file.save(os.path.join('/app/MsRewards-Reborn/user_data/', filename))
|
||||
return redirect(url_for('download_file', name=filename))
|
||||
|
||||
def maxi(dict):
|
||||
m = 0
|
||||
|
Reference in New Issue
Block a user