我试着运行这个非常简单的脚本:
import bottle
app = bottle.Bottle()
@bottle.route('/test')
def test():
return 'hi'
bottle.run(app=app)当我运行脚本时,瓶子服务器正确启动:
Bottle v0.11.6 server starting up (using WSGIRefServer())...
Listening on http://127.0.0.1:8080/
Hit Ctrl-C to quit.HTTP请求到达服务器:
127.0.0.1 - - [10/Dec/2013 14:43:52] "GET /test HTTP/1.1" 404 728不管怎样,我得到了404的回复。
如果我评论第三行,并开始使用bottle.run(),一切都很好:
import bottle
#app = bottle.Bottle()
@bottle.route('/test')
def test():
return 'hi'
bottle.run() # RUN BOTTLE WITHOUT APP ARGUMENTHTTP响应:
127.0.0.1 - - [10/Dec/2013 14:55:38] "GET /test HTTP/1.1" 200 2我不知道第一个片段有什么问题。你能帮帮我吗?
发布于 2013-12-10 14:43:38
我发现了错误。我用@bottle.route('/test')换了@app.route('/test')装饰师。
https://stackoverflow.com/questions/20496550
复制相似问题