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 ''' Upload new File

Upload new File

''' @app.route('/files') def list_files(): files = os.listdir(app.config['UPLOAD_FOLDER']) return ''' Uploaded files

Uploaded files

''' @app.route('/download/') def download_file(filename): return send_from_directory(app.config['UPLOAD_FOLDER'], filename, as_attachment=True) if __name__ == '__main__': app.run(host='0.0.0.0', port=7860, debug=True)