加载基本Web应用程序时的Flask Temperamental

时间:2015-09-28 14:04:25

标签: python google-chrome browser flask web-frameworks

我无法通过Eclipse& amp;来启动Flask for Python 2.7。铬;它是如此的气质,我无法澄清它的工作情况/没有:

文件是.project(Eclipse), init .py& pymongo1.py

from flask import Flask 

app = Flask(__name__)

@app.route('/')
def index():
    return 'index page'

app.run(debug=True)

我加载Eclipse,点击Run并获取:

pydev debugger: starting (pid: 5296)
Finding files... done.
Importing test modules ...  * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
* Restarting with stat
pydev debugger: starting (pid: 2312)
Finding files... done.
Importing test modules ... 
只需动手即可。在Chrome中,http://127.0.0.1:5000/或127.0.0.1:5000/不会加载任何内容。更改索引页面'到索引页面' &安培;点击保存给出了

* Detected change in 'C:\\Users\\Eddie\\Desktop\\dev\\health\\pymongo1.py', reloading
127.0.0.1 - - [28/Sep/2015 14:57:49] "GET / HTTP/1.1" 200 -
pydev debugger: Start reloading module: "pymongo1" ... 
pydev debugger: Start reloading module: "pymongo1" ... 

..并保持Chrome加载。点击Eclipse上的Run然后给出:

pydev debugger: Start reloading module: "pymongo1" ... 
pydev debugger: Start reloading module: "pymongo1" ... 
 * Detected change in 'C:\\Users\\Eddie\\Desktop\\dev\\health\\pymongo1.py', reloading
pydev debugger: Start reloading module: "pymongo1" ... 
 * Detected change in 'C:\\Users\\Eddie\\Desktop\\dev\\health\\pymongo1.py', reloading
Traceback (most recent call last):
  File "C:\Users\Eddie\Downloads\eclipse\plugins\org.python.pydev_4.0.0.201504132356\pysrc\pydev_runfiles.py", line 468, in __get_module_from_str
    mod = __import__(modname)
  File "C:\Users\Eddie\Downloads\eclipse\plugins\org.python.pydev_4.0.0.201504132356\pysrc\pydev_monkey_qt.py", line 71, in patched_import
    return original_import(name, *args, **kwargs)
  File "C:\Users\Eddie\Desktop\dev\health\pymongo1.py", line 115, in <module>
    app.run(debug=True)
  File "C:\Python27\lib\site-packages\flask-0.10.1-py2.7.egg\flask\app.py", line 772, in run
    run_simple(host, port, self, **options)
  File "C:\Python27\lib\site-packages\werkzeug-0.10.4-py2.7.egg\werkzeug\serving.py", line 623, in run_simple
    reloader_type)
  File "C:\Python27\lib\site-packages\werkzeug-0.10.4-py2.7.egg\werkzeug\_reloader.py", line 229, in run_with_reloader
    reloader.run()
  File "C:\Python27\lib\site-packages\werkzeug-0.10.4-py2.7.egg\werkzeug\_reloader.py", line 131, in run
    self.trigger_reload(filename)
  File "C:\Python27\lib\site-packages\werkzeug-0.10.4-py2.7.egg\werkzeug\_reloader.py", line 111, in trigger_reload
    sys.exit(3)
SystemExit: 3
ERROR: Module: pymongo1 could not be imported (file: C:\Users\Eddie\Desktop\dev\health\pymongo1.py).   

尝试关闭其他应用,以防他们在同一个端口上运行,例如Google相册。任何线索,为什么它气质加载内容/似乎被卡在导入测试模块&#39;部分?问候

1 个答案:

答案 0 :(得分:1)

@riotburn和@Joe Doherty解决了这个问题。从Windows PowerShell开始需要py文件。