Làm cách nào để đặt mã trạng thái HTTP của phản hồi của tôi trong Chai?Đặt mã trạng thái HTTP trong Chai?
from bottle import app, run, route, Response
@route('/')
def f():
Response.status = 300 # also tried `Response.status_code = 300`
return dict(hello='world')
'''StripPathMiddleware defined:
http://bottlepy.org/docs/dev/recipes.html#ignore-trailing-slashes
'''
run(host='localhost', app=StripPathMiddleware(app()))
Như bạn thấy, sản lượng không trả về mã trạng thái HTTP tôi đặt:
$ curl localhost:8080 -i
HTTP/1.0 200 OK
Date: Sun, 19 May 2013 18:28:12 GMT
Server: WSGIServer/0.1 Python/2.7.4
Content-Length: 18
Content-Type: application/json
{"hello": "world"}
thực hiện phản hồi nhập khẩu từ chai; response.status = 300' làm việc? http://bottlepy.org/docs/dev/api.html#bottle.response – dm03514
Vâng, điều đó đã làm được điều đó. Cảm ơn :) –