Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from flask import Flask, render_template, request
- import os
- app = Flask(__name__)
- UPLOAD_FOLDER = 'uploads'
- app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
- if not os.path.exists(UPLOAD_FOLDER):
- os.makedirs(UPLOAD_FOLDER)
- @app.route('/')
- def index():
- return render_template('index.html')
- @app.route('/upload', methods=['POST'])
- def upload():
- if 'file' not in request.files:
- return 'No file part'
- files = request.files.getlist('file')
- for file in files:
- file.save(os.path.join(app.config['UPLOAD_FOLDER'], file.filename))
- return 'Files uploaded successfully'
- if __name__ == '__main__':
- app.run(debug=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement