Handling File Uploads With Flask - miguelgrinberg.com

PHOTO EMBED

Tue Sep 06 2022 14:19:49 GMT+0000 (Coordinated Universal Time)

Saved by @Rmin #python #flask #validation

@app.errorhandler(413)
def too_large(e):
    return "File is too large", 413
content_copyCOPY

The 413 error for the file too large condition is generated by Flask when the request payload is bigger than the size set in the configuration. To override the default error page we have to use the app.errorhandler decorator:

https://blog.miguelgrinberg.com/post/handling-file-uploads-with-flask