在Virtualenv设置中Flask不工作

2024-06-28 11:32:22 发布

您现在位置:Python中文网/ 问答频道 /正文

设置

VirtualBox | Ubuntu Server 12.04.2
(flaskve)vks@UbSrVb:~/flaskve$ python --version
Python 2.7.3
ifconfig
192.168.1.100 (the bridge interface on which i interact with VirtualBox)

我要运行的代码。在

from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello World!'

if __name__ == '__main__':
    app.run(host='192.168.1.100', port=8080, debug=True)

当我这么做的时候

^{pr2}$

它不运行也不执行任何操作,只返回到命令提示符。虽然我在debug=True模式下运行。
然后我做了一个新的VirtualEnv并在里面安装了瓶子。当我尝试运行helloworld时,它也表现出同样的行为。
然而,我在同一个virtualenv上启动了pythonshell,导入了瓶子模块并运行

>>> from bottle import route, run
>>> run(host='192.168.1.100', port=8081, debug=True)
Bottle v0.11.6 server starting up (using WSGIRefServer())...
Listening on http://192.168.1.100:8081/
Hit Ctrl-C to quit.  

有什么问题吗? 即使调试也不显示任何内容。
以下链接是python -v start.py
http://paste.ubuntu.com/5713138/


Tags: runnamefromdebugimporttrueapphost