update,
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
from flask import Flask, request, send_from_directory
|
||||
from werkzeug.utils import secure_filename
|
||||
import tempfile
|
||||
import json
|
||||
from pprint import pprint
|
||||
from flask_cors import CORS
|
||||
|
||||
|
||||
|
||||
app = Flask(__name__)
|
||||
app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024
|
||||
app.config['UPLOAD_FOLDER'] = tempfile.gettempdir()
|
||||
|
||||
CORS(app)
|
||||
|
||||
@app.route('/uploader', methods = ['GET', 'POST'])
|
||||
def upload_file():
|
||||
if request.method == 'POST':
|
||||
print("hello post request")
|
||||
pprint(request.files)
|
||||
# f = request.files['file']
|
||||
# f.save(secure_filename(f.filename))
|
||||
# print("helloworld")
|
||||
# return json.dumps({'hello':'world'})
|
||||
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)
|
||||
|
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -ex
|
||||
|
||||
npx nodemon --ext py --exec "python ./main.py"
|
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# curl -X POST -H "Content-Type: application/json" -d '{"name":"John Doe","age":30}' http://localhost:5000/api/data
|
||||
|
||||
# curl http://localhost:5000/api/data
|
||||
curl -F "file=@test.txt" http://localhost:5000/uploader
|
@@ -0,0 +1 @@
|
||||
helloworld
|
Reference in New Issue
Block a user