我刚开始使用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: '/'
请让我知道该设置有什么问题。
答案 0 :(得分:2)
只需将bottle.run(application = APP)应用程序arg名称替换为app
bottle.run(app=APP)