This commit is contained in:
Channel Cat 2016-10-03 07:27:54 +00:00
parent 7cdeff63f6
commit ee98c8b42f
5 changed files with 49 additions and 50 deletions

View File

@ -1,3 +1,3 @@
uvloop
httptools httptools
ujson ujson
uvloop

View File

@ -1,3 +1,5 @@
from urllib.parse import parse_qs
class Request: class Request:
__slots__ = ('protocol', 'url', 'headers', 'version', 'method', 'query_string', 'body', 'parsed_json', 'parsed_args') __slots__ = ('protocol', 'url', 'headers', 'version', 'method', 'query_string', 'body', 'parsed_json', 'parsed_args')

View File

@ -1,4 +1,7 @@
import ujson import ujson
import httptools
from ujson import loads as json_loads
from urllib.parse import parse_qs
STATUS_CODES = { STATUS_CODES = {
200: 'OK', 200: 'OK',
@ -18,7 +21,7 @@ class HTTPResponse:
__slots__ = ('body', 'status', 'content_type') __slots__ = ('body', 'status', 'content_type')
def __init__(self, body='', status=200, content_type='text/plain'): def __init__(self, body='', status=200, content_type='text/plain'):
self.content_type = 'text/plain' self.content_type = content_type
self.body = body self.body = body
self.status = status self.status = status

View File

@ -7,7 +7,6 @@ import httptools
import logging import logging
from inspect import isawaitable from inspect import isawaitable
from ujson import loads as json_loads from ujson import loads as json_loads
from urllib.parse import parse_qs
from traceback import format_exc from traceback import format_exc
import httptools import httptools
@ -159,7 +158,6 @@ def abort(msg):
log.info(msg, file=sys.stderr) log.info(msg, file=sys.stderr)
sys.exit(1) sys.exit(1)
def serve(sanic, host, port, debug=False): def serve(sanic, host, port, debug=False):
# Create Event Loop # Create Event Loop
loop = async_loop.new_event_loop() loop = async_loop.new_event_loop()

View File

@ -8,10 +8,6 @@ app = Sanic("test")
async def test(request): async def test(request):
return json({ "test": True }) return json({ "test": True })
@app.route("/text")
def test(request):
return text('hi')
@app.route("/exception") @app.route("/exception")
def test(request): def test(request):
raise ServerError("yep") raise ServerError("yep")