【问题标题】:Internal Server Error 500 in Mongod for Python codeMongod for Python 代码中的内部服务器错误 500
【发布时间】: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
  • 你在哪里定义sessionsposts?好像您错过了 pymongo 连接呼叫。
  • 所有数据都是由 10gen 人预先定义的。我找到了答案,我的应用现在正在运行

标签: python mongodb bottle


【解决方案1】:

只要您知道您用 python 编写的代码是正确的代码,请寻找软件答案。

您可能需要重新启动服务器才能加载新代码,或者在我的情况下,删除数据库;

我自己使用了数据库,并不是所有的文件都有日期;

在调用路由/时,由于部分文档中没有date属性,产生了错误。

另外,在编写代码时检查字段,因为可能缺少字段。

在我删除数据库、创建新用户、新帖子、添加 cmets 后,我验证了代码并得到了答案。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-09-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-09
    • 2015-11-22
    • 2018-11-14
    • 2016-04-24
    相关资源
    最近更新 更多