Python的瓶教程:无法获取来自HelloWorld示例什么(Python Bottle Tuto

2019-10-20 14:22发布

I just installed Bottle and add it into this directory: /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3

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!

Answer 1:

我有同样的问题。 更换“localhost”的与“127.0.0.1”,并得到了一个404页面未找到。 然而,在快速入门教程中的第二个例子的工作:

from bottle import Bottle, run

app = Bottle()

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

run(app, host='localhost', port=8080)


Answer 2:

如果它不是本地主机与工作,但它正在与127.0.0.1,这意味着你的网络配置是不是真的正确设置。

如果你是在Linux或Mac,检查/ etc / hosts文件,并查找:

127.0.0.1本地主机

Windows有在%SYSTEMROOT%\ SYSTEM32 \ DRIVERS相同的文件\等\主机。

如果该行不存在,添加它。



文章来源: Python Bottle Tutorial: cannot get anything from the HelloWorld example
标签: python bottle