web2py custom 404 page when I raise the 404 myself?

半腔热情 提交于 2019-12-11 12:56:22

问题


I have a function in my controller that take an HTTP GET request. On certain argument values of that request I want to raise a 404. I also want that 404 to get rerouted to a different html page that I can make instead of giving that generic

404 NOT FOUND

or whatever with a message. I made a routes.py which is in the root directory of my application and it contains

routes_onerror[('myapp/404', 'myapp/static/404.html')]

And I also have a 404.HTML in my static folder. Is what I am trying to do the intended use of routes?


回答1:


Missing an =, and the URL should be preceded by a /:

routes_onerror = [('myapp/404', '/myapp/static/404.html')]


来源:https://stackoverflow.com/questions/17351528/web2py-custom-404-page-when-i-raise-the-404-myself

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!