This commit is contained in:
louiscklaw
2025-01-31 22:59:38 +08:00
parent 2f380a6c09
commit cd81c1cd1e
32 changed files with 4917 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
from flask import Flask, request, send_from_directory
from werkzeug.utils import secure_filename
import tempfile
app = Flask(__name__)
app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024
app.config['UPLOAD_FOLDER'] = tempfile.gettempdir()
@app.route('/uploader', methods = ['GET', 'POST'])
def upload_file():
if request.method == 'POST':
f = request.files['file']
f.save(secure_filename(f.filename))
print("helloworld")
return json.dumps({'hello':'world'})
@app.route('/uploads/<filename>')
def download_file(filename):
return send_from_directory(app.config['UPLOAD_FOLDER'], filename)
if __name__ == '__main__':
app.run(debug = True)

View File

@@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -ex
curl -F "file=@test.txt" http://localhost:5000/uploader

View File

@@ -0,0 +1 @@
helloworld