如何防止Python Bottle向控制台报告每个请求?

时间:2015-06-06 07:00:15

标签: python bottle

我正在使用Python Bottle运行服务器。它工作得非常好,但是它会将它处理的每个请求记录到控制台,这会减慢它的速度。有没有办法指示将这些日志发送到控制台?

示例代码:

from bottle import route, run
@route('/')
def index():
    return 'Hello, world!'
run(host = 'localhost', port = 8080)

示例输出(每次向localhost:8080/发出请求时都会得到):

127.0.0.1 - - [06/Jun/2015 11:23:24] "GET / HTTP/1.1" 200 244

1 个答案:

答案 0 :(得分:6)

quiet参数添加到run来电:

from bottle import route, run

@route('/')
def index():
    return 'Hello, world!'

run(host = 'localhost', port = 8080, quiet=True)

请参阅API reference