【发布时间】:2021-01-04 10:45:33
【问题描述】:
我刚刚开始使用 Bottle。我在GitHub 上找到了一个示例应用程序。该示例只有一个 server.py 文件,如下所示
import bottle
APP = bottle.Bottle()
@APP.get('/')
def index():
return '<p>Hello</p>'
if __name__ == '__main__':
bottle.run(application=APP)
requirements.txt 文件有
bottle
gunicorn
作为依赖项。我正在使用 Python 3.7.2。运行 pip install -r requirements.txt 后,我运行了 python server.py。服务器在端口 8080 上正常启动
Bottle v0.12.18 server starting up (using WSGIRefServer(application=<bottle.Bottle object at 0x1040fa2d0>))...
Listening on http://127.0.0.1:8080/
当我访问 http://localhost:8080 时,我得到了
Error: 404 Not Found
Sorry, the requested URL 'http://localhost:8080/' caused an error:
Not found: '/'
请告诉我设置有什么问题。
【问题讨论】:
标签: python python-3.x bottle