from flask import Flask, request, send_from_directory,abort import os app = Flask(__name__) UPLOAD_FOLDER = 'uploads' if not os.path.exists(UPLOAD_FOLDER): os.makedirs(UPLOAD_FOLDER) app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER @app.route('/', methods=['GET', 'POST']) def home(): abort(500, "Server Error") @app.route('/upload', methods=['GET', 'POST']) def upload_file(): if request.method == 'POST': if 'file' not in request.files: return 'No file part' file = request.files['file'] if file.filename == '': return 'No selected file' if file: filename = file.filename file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) return 'File uploaded successfully' return '''