Python Bottle教程:无法从HelloWorld示例获得任何信息 [英] Python Bottle Tutorial: cannot get anything from the HelloWorld example
问题描述
我刚刚安装了Bottle,并将其添加到以下目录中: /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3
I just installed Bottle and add it into this directory: /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3
当我尝试在中运行HelloWorld示例时http://bottlepy.org/docs/dev/tutorial.html#installation
并打开 localhost:8080 / hello
,
And when I was trying to run the HelloWorld example in http://bottlepy.org/docs/dev/tutorial.html#installation
and opened localhost:8080/hello
, there was nothing on the page.
>>> from bottle import route, run
>>>
>>> @route('/hello')
... def hello():
... return "Hello World!"
...
>>> run(host='localhost', port=8080, debug=True)
Bottle v0.13-dev server starting up (using WSGIRefServer())...
Listening on http://localhost:8080/
Hit Ctrl-C to quit.
我不知道为什么,请帮忙!
I don't know why, please help!
推荐答案
我遇到了同样的问题。将 localhost替换为 127.0.0.1,并显示 404未找到页面。
但是,快速入门教程中的第二个示例起作用了:
I had the same problem. Replaced 'localhost' with '127.0.0.1' and got a 404 Not Found page. However, the second example in the quickstart tutorial worked:
from bottle import Bottle, run
app = Bottle()
@app.route('/hello')
def hello():
return "Hello World!"
run(app, host='localhost', port=8080)
这篇关于Python Bottle教程:无法从HelloWorld示例获得任何信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!