Flask应用程序无法启动,我正在按照教程进行操作

时间:2013-10-21 18:14:51

标签: python flask

我正在尝试按照本教程...

http://flask.pocoo.org/docs/tutorial/setup/#tutorial-setup

尝试让一个简单的烧瓶应用程序运行。我想我几乎完全按照他们的代码,但我遇到了问题。我的代码是......

from flask import Flask, request, session, g, redirect, url_for, \
    abort, render_template, flash

# configuration
DATABASE = ''
DEBUG = True
SECRET_KEY = 'development key'
USERNAME = 'admin'
PASSWORD = 'default'

sandra_source= Flask(__name__)
sandra_source.config.from_object(__name__)

def main():
    sandra_source.run()

main()

我认识到数据库不一样,但除此之外,它很有意义。但是,我一直收到错误

AttributeError: 'module' object has no attribute 'sandra_service'

我的模块名为sandra_service,所以我不确定这个错误是怎么发生的。

堆栈跟踪

AttributeError: 'module' object has no attribute 'sandra_service'
0     SandraImporter.load_module() c:\working\qzpkgs\quartz-14324978\win32_vc9\pylib\sandra\sandra_import.py:208
1     <module>()                   /playground/nbkiq0w/rester_app_root/services/sandra_service.py:20
2     Config.from_object()         D:\quartz\WINSLA~1\WIN32-~1\build\ext\noarch\lib\python2.6\flask\config.py:146
3 --> import_string()              D:\quartz\WINSLA~1\WIN32-~1\build\ext\noarch\lib\python2.6\werkzeug\utils.py:529

1 个答案:

答案 0 :(得分:0)

不确定这是否是一个很好的答案,但我删除了

sandra_source.config.from_object(__name__)

这一行,现在代码似乎至少在编译/运行。希望以后不会出现更多问题。