Answer the question
In order to leave comments, you need to log in
How to upload file via flask rest-api?
I'm using the standard file upload feature from the Flask documentation
@app.route('/', methods=['GET', 'POST'])
def index():
if request.method == 'POST':
if 'file' not in request.files:
flash('No file part')
return redirect(request.url)
file = request.files['file']
if file.filename == '':
flash('NO selected file')
return redirect(request.url)
print(file.filename)
if not allowed_file(file.filename):
flash("Only JPG file is used")
return redirect(request.url)
if file and allowed_file(file.filename):
filename = secure_filename(file.filename)
file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
img = (os.path.join(app.config['UPLOAD_FOLDER'], filename))
_, count = performDetect(imagePath=img)
return redirect(url_for("result", count=count))
return render_template("index.html")
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question