我有带有路线的控制器:
@http.route(['/report/yandex_phone_report'], type='http', auth="public", website=True)
def yandex_phone_report(self, **kw):
page_data = []
return http.request.render(self._report_index_page_template, {
'page_items': page_data
如果我登录 URL /report/yandex_phone_report 显示正常。
如果我没有登录 URL /report/yandex_phone_report 将返回 404:
2017-08-02 16:46:09,400 5942 INFO ? werkzeug: 127.0.0.1 - - [02/Aug/2017 16:46:09] "GET /report/yandex_phone_report HTTP/1.1" 404 -
浏览器显示如下:
Not Found
The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.
我该如何修复它?为什么路由不起作用?
发生这种情况是因为它不知道在哪个数据库上查找该 URL。
如果您查看您提供的日志,您会看到 INFO 之后有 ?
2017-08-02 16:46:09,400 5942 INFO ? <- THIS ONE
如果它知道应该使用哪个数据库,您会看到一个数据库名称,而不是 ?。
要测试它,您可以首先调用:http://localhost:PORT/web?db=YOUR_DB_NAME http://localhost:PORT/web?db=YOUR_DB_NAME
这将在浏览器上为给定的数据库设置会话。
然后,调用http://localhost:PORT/report/yandex_phone_report http://localhost:PORT/report/yandex_phone_report将工作。
在生产环境中,您需要将其配置为从某处获取数据库名称...例如从 URL (http://dbname.example.com:端口 http://dbname.example.com:PORT).
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)