py4web: json-response on server errors

22 views
Skip to first unread message

Val K

unread,
Mar 10, 2020, 5:21:49 PM3/10/20
to web2py-users
Hello!
I'd like to discuss my PR  https://github.com/web2py/py4web/pull/123

The reason:
Currently, if you make an ajax request and expect json-response, in case of any error on the server, py4web returns a response that is an html page with response.status = 200. My PR changes this behavior to the following logic - if there is `application / json` in the http_accept-header, a json is returned that contains the same information as the html error-page with the actual response.status, so the error can be caught using the appropriate callback (this is a more common practice)

   
Reply all
Reply to author
Forward
0 new messages