【发布时间】:2013-05-23 20:21:26
【问题描述】:
我对在我的 mongo 数据库中制作一个非常薄的烧瓶接口很感兴趣——只需几个简单的索引和表单来显示和编辑我的数据。
我正在关注来自 MongoDB 的 this tutorial,还有一些补充 from this one 也很有帮助。
我第一次运行python manage.py runserver 时,一切正常。但是在添加视图和模板之后,第二次运行 python manage.py runserver 应用程序似乎失败了:
Internal Server Error
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.
我有app.run(debug=True),但控制台中没有额外的错误记录:
$ python manage.py runserver
* Running on http://localhost:5000/
* Restarting with reloader
127.0.0.1 - - [28/May/2013 14:45:14] "GET / HTTP/1.1" 500 -
127.0.0.1 - - [28/May/2013 14:45:14] "GET /favicon.ico/ HTTP/1.1" 404 -
其他人有这个问题吗?教程中是否缺少某些内容,或者是否有更好的方法来找出我的错误在哪里?任何其他关于在 MongoDB 上设置最小 Flask 层的建议也将不胜感激!
【问题讨论】:
-
我完成了那个教程,并记得其中有一些我必须修复的错误。你能分享你的代码吗?
-
确实,我们需要查看一些代码才能弄清楚。但是,这个错误对我来说似乎也有点熟悉。本教程使用一种 hack 将父目录包含在系统路径中,这是在 manage.py 文件中完成的。确保设置正确。
-
我会看看我是否可以以一种有意义的方式列出文件,或者上传到 github 或其他东西。与此同时,泰斯曼,我认为你对黑客的看法是正确的。我在交互式命令行中运行了以下命令:
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))),它有一些抱怨。__file__未定义。 -
您不能直接在命令行上引用
__file__,因为它仅在实际文件/模块中定义。尝试在github上分享你的代码,我们可以看看。
标签: mongodb flask pymongo mongoengine