【发布时间】:2013-04-22 20:13:39
【问题描述】:
我正在学习 MongoDB m101p 课程,但遇到了麻烦;
- 开始
mongod - 开始
python blog.py监听器 - 使用现有用户登录
- 添加了一个新帖子
- 在该帖子中添加了 cmets
问题是每个定义的 url 都有效,不包括根 url localhost:8082/
当我想进入着陆页时,我得到error: 500 internal server error
每次修改代码时,我都会重新启动 python 监听器。
我无法验证代码,因为根 url 不起作用
有什么想法吗?/ route:
# This route is the main page of the blog
@bottle.route('/')
def blog_index():
cookie = bottle.request.get_cookie("session")
username = sessions.get_username(cookie)
# even if there is no logged in user, we can show the blog
l = posts.get_posts(10)
return bottle.template('blog_template', dict(myposts=l, username=username))
【问题讨论】:
-
开启调试。瓶子应该有一个选项。
-
将
debug=True传递给您的瓶子run函数调用,因为它已完成 here。 -
你在哪里定义
sessions和posts?好像您错过了pymongo连接呼叫。 -
所有数据都是由 10gen 人预先定义的。我找到了答案,我的应用现在正在运行