I must upload file to flask via curl command. I tried sending using the curl commands from Folder/Files Upload with Flask and it failed to identify the request.
curl --form "fileupload=@filename.txt" http://hostname/resource
And the Python code:
from flask import Flask,abort,render_template,request,redirect,url_for
from werkzeug import secure_filename
import os
app = Flask(__name__)
UPLOAD_FOLDER = './uploads'
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
@app.route('/upload/',methods = ['POST'])
def upload_file():
if request.method =='POST':
file = request.files['file']
print request.files
if file:
filename = secure_filename(file.filename)
file.save(os.path.join(app.config['UPLOAD_FOLDER'],filename))
if __name__ == '__main__':
app.run(debug = True)
The data should be saved upon POSTing via CURL command