add status codes and teapot example
This commit is contained in:
parent
d8c8ccd180
commit
2e5d1ddff9
13
examples/teapot.py
Normal file
13
examples/teapot.py
Normal 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)
|
|
@ -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',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user