Skip to content

Commit

Permalink
Update app.py
Browse files Browse the repository at this point in the history
  • Loading branch information
tiritibambix authored Dec 18, 2024
1 parent e01a553 commit 22da84e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,19 @@ def index():
return render_template('index.html')

# Téléchargement d'une image depuis l'ordinateur
@app.route('/upload', methods=['POST'])
@app.route('/upload', methods=['GET', 'POST'])
def upload_file():
if request.method == 'GET':
# Affiche un formulaire pour téléverser un fichier
return render_template('upload.html')

if 'file' not in request.files:
flash('Aucun fichier sélectionné.')
return redirect(request.url)
return redirect(url_for('index'))
file = request.files['file']
if file.filename == '':
flash('Aucun fichier sélectionné.')
return redirect(request.url)
return redirect(url_for('index'))
if file and allowed_file(file.filename):
filename = secure_filename(file.filename)
filepath = os.path.join(app.config['UPLOAD_FOLDER'], filename)
Expand Down

0 comments on commit 22da84e

Please sign in to comment.