aucune idée de ce que je fais
This commit is contained in:
parent
e099f705c8
commit
b3f13399a4
37
Flask/app.py
37
Flask/app.py
|
@ -165,7 +165,7 @@ def change_password():
|
|||
|
||||
# handle login failed
|
||||
@app.errorhandler(401)
|
||||
def page_not_found(e):
|
||||
def unauthorized(e):
|
||||
return(render_template("login.html"))
|
||||
|
||||
|
||||
|
@ -416,8 +416,9 @@ 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):
|
||||
ALLOWED_EXTENSIONS = ["json"]
|
||||
return '.' in filename and \
|
||||
filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
|
||||
|
||||
|
@ -425,21 +426,23 @@ def allowed_file(filename):
|
|||
@login_required
|
||||
def upload_file():
|
||||
print(request.files)
|
||||
print(request)
|
||||
# check if the post request has the file part
|
||||
if 'file1' not in request.files:
|
||||
print('No file part')
|
||||
return redirect(url_for('settings_get'))
|
||||
file = request.files['file1']
|
||||
# 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(url_for('settings_get'))
|
||||
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('settings_get'))
|
||||
i = 1
|
||||
while f'file{i}' in request.files :
|
||||
file = request.files[f'file{i}']
|
||||
if file.filename == '':
|
||||
print('end of files')
|
||||
return redirect(url_for('settings_get'))
|
||||
elif file and allowed_file(file.filename):
|
||||
filename = secure_filename(file.filename)
|
||||
print(os.path.join('/app/MsRewards-Reborn/user_data/', filename))
|
||||
file.save(os.path.join('/app/MsRewards-Reborn/user_data/', filename))
|
||||
|
||||
i += 1
|
||||
|
||||
print("requete bizarre")
|
||||
return redirect(url_for('settings_get'))
|
||||
|
||||
|
||||
|
||||
return redirect(url_for('settings_get'))
|
||||
|
||||
|
|
Loading…
Reference in New Issue