我有带路由的控制器:
@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
Run Code Online (Sandbox Code Playgroud)
如果我登录 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 -
Run Code Online (Sandbox Code Playgroud)
浏览器显示:
Not Found
The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.
Run Code Online (Sandbox Code Playgroud)
我该如何解决?为什么路由不起作用?
小智 5
发生这种情况是因为它不知道在哪个数据库上查找该 URL。
如果您查看您提供的日志,您会看到在 INFO 之后,您有 ?
2017-08-02 16:46:09,400 5942 INFO ? <- THIS ONE
Run Code Online (Sandbox Code Playgroud)
如果它知道应该使用哪个数据库,您会看到一个数据库名称,而不是 ?。
要测试它,您可以先调用:http://localhost:PORT/web?db=YOUR_DB_NAME
这将为给定的数据库在浏览器上设置会话。
然后,调用http://localhost:PORT/report/yandex_phone_report就可以了。
在生产环境中,您需要对其进行配置以从某处获取数据库名称...例如从 URL ( http://dbname.example.com:PORT )。