diff --git a/Flask/app.py b/Flask/app.py index 395c72f..b221ecd 100644 --- a/Flask/app.py +++ b/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 diff --git a/Flask/templates/settings.html b/Flask/templates/settings.html index ca480b9..dff69a5 100644 --- a/Flask/templates/settings.html +++ b/Flask/templates/settings.html @@ -64,12 +64,16 @@ logs viewer -

Backup config files

-download account config -download discord config -download flask config -download proxy config -download settings + +

Backup config files

+ + + + + + +
download account config
download discord config
download flask config
download proxy config
download settings
+ {% endif %} {%endblock %}