在 Tipfy 的 Hello World 教程之后出现 404 错误
我确信我在这里遗漏了一些令人尴尬的明显内容,但是当我遵循 Tipfy 的 Hello World 教程时,每当我尝试加载 urls.py 文件中定义的 URL 之一(在 /项目/应用程序/应用程序/hello_world)。
我已确保“apps.hello_world”位于 config.py 中“apps_installed”字典中已安装应用程序的列表中。其他一切似乎都按顺序进行,我已经阅读并阅读了仔细遵循教程和入门指南中的说明,但我不明白为什么 Tipfy 没有检测到我在 hello_world 应用程序的 urls.py 文件中的 get_rules() 中定义的规则。
以下是该文件中的代码:
from tipfy import Rule
def get_rules(app):
rules = [
Rule('/', endpoint='hello/world', handler='handlers.HelloWorldHandler'),
Rule('/hello-jinja', endpoint='hello/jinja', handler='handlers.HelloJinjaHandler'),
Rule('/hello-json', endpoint='hello/json', handler='handlers.HelloJsonHandler'),
Rule('/hello-ajax', endpoint='hello/ajax', handler='handlers.HelloAjaxHandler'),
]
return rules
非常感谢任何人可以提供的帮助 - 谢谢!
I'm sure I am missing something embarrassingly obvious here, but as I am following Tipfy's Hello World tutorial, I'm getting nothing but Werkzeug's 404 page whenever I try to load one of the URLs defined in my urls.py file (in /project/app/apps/hello_world).
I've ensured that 'apps.hello_world' is in the list of installed apps in the 'apps_installed' dictionary in config.py. Everything else seems to be in order, and I've read & followed the instructions in the tutorial and Getting Started guide carefully, but I can't see why Tipfy isn't detecting the rules I defined in get_rules() in my hello_world app's urls.py file.
Here is the code from that file:
from tipfy import Rule
def get_rules(app):
rules = [
Rule('/', endpoint='hello/world', handler='handlers.HelloWorldHandler'),
Rule('/hello-jinja', endpoint='hello/jinja', handler='handlers.HelloJinjaHandler'),
Rule('/hello-json', endpoint='hello/json', handler='handlers.HelloJsonHandler'),
Rule('/hello-ajax', endpoint='hello/ajax', handler='handlers.HelloAjaxHandler'),
]
return rules
Any help anyone can offer is greatly appreciated - thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没关系。我解决了。尽管我在 Tipfy 文档中找不到它,尽管事实上我仍然是 Python 的新手,但我想我应该知道 apps 目录中的“hello_world”目录需要一个
__init__ .py
文件以便被视为模块Nevermind. I solved it. Although it was nowhere in the Tipfy documentation that I could find, and despite the fact that I'm still a solid newbie with Python, I guess I should have known that my 'hello_world' directory in the apps directory needed an
__init__.py
file in order to be treated as a module