add status codes and teapot example

This commit is contained in:
aiosin 2017-09-13 14:08:29 +02:00
parent d8c8ccd180
commit 2e5d1ddff9
2 changed files with 15 additions and 0 deletions

13
examples/teapot.py Normal file
View File

@ -0,0 +1,13 @@
from sanic import Sanic
from sanic import response as res
app = Sanic(__name__)
@app.route("/")
async def test(req):
return res.text("I\'m a teapot", status=418)
if __name__ == '__main__':
app.run(host="0.0.0.0", port=8000)

View File

@ -56,6 +56,7 @@ ALL_STATUS_CODES = {
415: b'Unsupported Media Type', 415: b'Unsupported Media Type',
416: b'Requested Range Not Satisfiable', 416: b'Requested Range Not Satisfiable',
417: b'Expectation Failed', 417: b'Expectation Failed',
418: b'I\'m a teapot',
422: b'Unprocessable Entity', 422: b'Unprocessable Entity',
423: b'Locked', 423: b'Locked',
424: b'Failed Dependency', 424: b'Failed Dependency',
@ -63,6 +64,7 @@ ALL_STATUS_CODES = {
428: b'Precondition Required', 428: b'Precondition Required',
429: b'Too Many Requests', 429: b'Too Many Requests',
431: b'Request Header Fields Too Large', 431: b'Request Header Fields Too Large',
451: b'Unavailable For Legal Reasons',
500: b'Internal Server Error', 500: b'Internal Server Error',
501: b'Not Implemented', 501: b'Not Implemented',
502: b'Bad Gateway', 502: b'Bad Gateway',