Flask file upload limit

I have a file upload handler for multiple file downloads and you set MAX_CONTENT_SIZE. The docs mention that Flask throws an exception 413 when the total file size exceeds the limit, so I also wrote an 413 error handler with a user page 413. However, when testing file downloads, I see that error 413 is definitely thrown, but the connection seems to be , is interrupted every time, and does not create my error page. FYI, I am using Flask dev server currently.

code:

app.config['MAX_CONTENT_LENGTH'] = 50 * 1024 * 1024    # 50 Mb limit

@app.route('/upload', methods=['POST'])
def upload_files():
    if request.method == 'POST':
       uploaded_files = request.files.getlist('uploaded_files[]')

       # do some stuff with these files



@app.errorhandler(413)
def error413(e):
    return render_template('413.html'), 413

UPDATE:

Well, strange, this problem only occurs when using the Flask dev server. I am testing it on Apache and my 413 error page looks great.

+4

All Articles