Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fr om flask import Flask, render_template, request
- from werkzeug import secure_filename
- app = Flask(__name__)
- @app.route('/upload', endpoint = 'upload_file1')
- def upload_file1():
- return render_template('view.html')
- @app.route('/uploader', methods = ['GET', 'POST'], endpoint= 'upload_file2')
- def upload_file2():
- if request.method == 'POST':
- f = request.files['file']
- f.save(secure_filename(f.filename))
- return 'file uploaded successfully'
- if __name__ == '__main__':
- app.run(debug = True)
- An exception has occurred, use %tb to see the full traceback.
- SystemExit: 1
- <html>
- <body>
- <form action = "http://localhost:5000/uploader" method = "POST"
- enctype = "multipart/form-data">
- <input type = "file" name = "file" />
- <input type = "submit"/>
- </form>
- </body>
- </html>
Add Comment
Please, Sign In to add comment