Skip to content Skip to sidebar Skip to footer

Python Flask - Both Json And Html 404 Error

I'm making a small web interface running on a raspberry pi at home. It hosts a little REST api as well as some web pages. I'm using Flask, and have a route '/' for the index, and s

Solution 1:

The best way I found to fix this is using blueprints.

I put my API in it's own blueprint, and there I can define an errorhandler for that blueprint alone.

The only problem is that when there are non-existing pages in the api the default errorhandler is used, rather than the one I defined for the api-blueprint. There are some workaround for that too, but this is a limitation of Flask aparently, no biggy.

Post a Comment for "Python Flask - Both Json And Html 404 Error"