-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app1.py
29 lines (22 loc) · 796 Bytes
/
app1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from flask import Flask, render_template, request, redirect, url_for
import os
app = Flask(__name__)
# Set the upload folder
UPLOAD_FOLDER = 'data'
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
# Route for the upload page
@app.route('/upload')
def upload_file():
return render_template('upload.html')
# Route for handling the file upload
@app.route('/uploader', methods=['POST'])
def upload_file_handler():
# Get the uploaded file
file = request.files['file']
# Save the file to the upload folder
filename = file.filename
file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
# Redirect to the upload page with a success message
return redirect(url_for('upload_file', message='File uploaded successfully.'))
if __name__ == '__main__':
app.run(debug=True)