Run linter
This commit is contained in:
@@ -9,10 +9,15 @@ import ujson as json
|
||||
loop = uvloop.new_event_loop()
|
||||
asyncio.set_event_loop(loop)
|
||||
|
||||
|
||||
async def handle(request):
|
||||
return web.Response(body=json.dumps({"test":True}).encode('utf-8'), content_type='application/json')
|
||||
return web.Response(
|
||||
body=json.dumps({"test": True}).encode("utf-8"),
|
||||
content_type="application/json",
|
||||
)
|
||||
|
||||
|
||||
app = web.Application(loop=loop)
|
||||
app.router.add_route('GET', '/', handle)
|
||||
app.router.add_route("GET", "/", handle)
|
||||
|
||||
web.run_app(app, port=sys.argv[1], access_log=None)
|
||||
|
||||
@@ -4,8 +4,9 @@ from bottle import route, run
|
||||
import ujson
|
||||
|
||||
|
||||
@route('/')
|
||||
@route("/")
|
||||
def index():
|
||||
return ujson.dumps({'test': True})
|
||||
return ujson.dumps({"test": True})
|
||||
|
||||
|
||||
app = bottle.default_app()
|
||||
|
||||
@@ -3,9 +3,11 @@
|
||||
import falcon
|
||||
import ujson as json
|
||||
|
||||
|
||||
class TestResource:
|
||||
def on_get(self, req, resp):
|
||||
resp.body = json.dumps({"test": True})
|
||||
|
||||
|
||||
app = falcon.API()
|
||||
app.add_route('/', TestResource())
|
||||
app.add_route("/", TestResource())
|
||||
|
||||
@@ -13,8 +13,14 @@ kyk = Kyoukai("example_app")
|
||||
logger = logging.getLogger("Kyoukai")
|
||||
logger.setLevel(logging.ERROR)
|
||||
|
||||
|
||||
@kyk.route("/")
|
||||
async def index(ctx: HTTPRequestContext):
|
||||
return ujson.dumps({"test":True}), 200, {"Content-Type": "application/json"}
|
||||
return (
|
||||
ujson.dumps({"test": True}),
|
||||
200,
|
||||
{"Content-Type": "application/json"},
|
||||
)
|
||||
|
||||
kyk.run()
|
||||
|
||||
kyk.run()
|
||||
|
||||
@@ -3,8 +3,10 @@ import sys
|
||||
import os
|
||||
import inspect
|
||||
|
||||
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
|
||||
sys.path.insert(0, currentdir + '/../../../')
|
||||
currentdir = os.path.dirname(
|
||||
os.path.abspath(inspect.getfile(inspect.currentframe()))
|
||||
)
|
||||
sys.path.insert(0, currentdir + "/../../../")
|
||||
|
||||
import timeit
|
||||
|
||||
@@ -16,7 +18,11 @@ print("Running New 100,000 times")
|
||||
times = 0
|
||||
total_time = 0
|
||||
for n in range(6):
|
||||
time = timeit.timeit('json({ "test":True }).output()', setup='from sanic.response import json', number=100000)
|
||||
time = timeit.timeit(
|
||||
'json({ "test":True }).output()',
|
||||
setup="from sanic.response import json",
|
||||
number=100000,
|
||||
)
|
||||
print("Took {} seconds".format(time))
|
||||
total_time += time
|
||||
times += 1
|
||||
@@ -26,7 +32,11 @@ print("Running Old 100,000 times")
|
||||
times = 0
|
||||
total_time = 0
|
||||
for n in range(6):
|
||||
time = timeit.timeit('json({ "test":True }).output_old()', setup='from sanic.response import json', number=100000)
|
||||
time = timeit.timeit(
|
||||
'json({ "test":True }).output_old()',
|
||||
setup="from sanic.response import json",
|
||||
number=100000,
|
||||
)
|
||||
print("Took {} seconds".format(time))
|
||||
total_time += time
|
||||
times += 1
|
||||
|
||||
@@ -2,8 +2,10 @@ import sys
|
||||
import os
|
||||
import inspect
|
||||
|
||||
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
|
||||
sys.path.insert(0, currentdir + '/../../../')
|
||||
currentdir = os.path.dirname(
|
||||
os.path.abspath(inspect.getfile(inspect.currentframe()))
|
||||
)
|
||||
sys.path.insert(0, currentdir + "/../../../")
|
||||
|
||||
from sanic import Sanic
|
||||
from sanic.response import json
|
||||
@@ -15,5 +17,6 @@ app = Sanic("test")
|
||||
async def test(request):
|
||||
return json({"test": True})
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(host="0.0.0.0", port=sys.argv[1])
|
||||
|
||||
@@ -2,8 +2,10 @@ import sys
|
||||
import os
|
||||
import inspect
|
||||
|
||||
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
|
||||
sys.path.insert(0, currentdir + '/../../../')
|
||||
currentdir = os.path.dirname(
|
||||
os.path.abspath(inspect.getfile(inspect.currentframe()))
|
||||
)
|
||||
sys.path.insert(0, currentdir + "/../../../")
|
||||
|
||||
from sanic import Sanic
|
||||
from sanic.response import json, text
|
||||
@@ -17,7 +19,7 @@ async def test(request):
|
||||
return json({"test": True})
|
||||
|
||||
|
||||
@app.route("/sync", methods=['GET', 'POST'])
|
||||
@app.route("/sync", methods=["GET", "POST"])
|
||||
def test(request):
|
||||
return json({"test": True})
|
||||
|
||||
@@ -44,7 +46,14 @@ def post_json(request):
|
||||
|
||||
@app.route("/query_string")
|
||||
def query_string(request):
|
||||
return json({"parsed": True, "args": request.args, "url": request.url, "query_string": request.query_string})
|
||||
return json(
|
||||
{
|
||||
"parsed": True,
|
||||
"args": request.args,
|
||||
"url": request.url,
|
||||
"query_string": request.query_string,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
import sys
|
||||
@@ -52,7 +61,6 @@ import sys
|
||||
app.run(host="0.0.0.0", port=sys.argv[1])
|
||||
|
||||
|
||||
|
||||
# import asyncio_redis
|
||||
# import asyncpg
|
||||
# async def setup(sanic, loop):
|
||||
|
||||
@@ -5,14 +5,14 @@ from tornado import ioloop, web
|
||||
|
||||
class MainHandler(web.RequestHandler):
|
||||
def get(self):
|
||||
self.write(ujson.dumps({'test': True}))
|
||||
self.write(ujson.dumps({"test": True}))
|
||||
|
||||
|
||||
app = web.Application([
|
||||
(r'/', MainHandler)
|
||||
], debug=False,
|
||||
app = web.Application(
|
||||
[(r"/", MainHandler)],
|
||||
debug=False,
|
||||
compress_response=False,
|
||||
static_hash_cache=True
|
||||
static_hash_cache=True,
|
||||
)
|
||||
|
||||
app.listen(8000)
|
||||
|
||||
@@ -12,16 +12,17 @@ from wheezy.web.middleware import path_routing_middleware_factory
|
||||
|
||||
import ujson
|
||||
|
||||
class WelcomeHandler(BaseHandler):
|
||||
|
||||
class WelcomeHandler(BaseHandler):
|
||||
def get(self):
|
||||
response = HTTPResponse(content_type='application/json; charset=UTF-8')
|
||||
response.write(ujson.dumps({"test":True}))
|
||||
response = HTTPResponse(content_type="application/json; charset=UTF-8")
|
||||
response.write(ujson.dumps({"test": True}))
|
||||
return response
|
||||
|
||||
|
||||
all_urls = [
|
||||
url('', WelcomeHandler, name='default'),
|
||||
# url('', welcome, name='welcome')
|
||||
url("", WelcomeHandler, name="default"),
|
||||
# url('', welcome, name='welcome')
|
||||
]
|
||||
|
||||
|
||||
@@ -29,18 +30,19 @@ options = {}
|
||||
main = WSGIApplication(
|
||||
middleware=[
|
||||
bootstrap_defaults(url_mapping=all_urls),
|
||||
path_routing_middleware_factory
|
||||
path_routing_middleware_factory,
|
||||
],
|
||||
options=options
|
||||
options=options,
|
||||
)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
from wsgiref.simple_server import make_server
|
||||
|
||||
try:
|
||||
print('Visit http://localhost:{}/'.format(sys.argv[-1]))
|
||||
make_server('', int(sys.argv[-1]), main).serve_forever()
|
||||
print("Visit http://localhost:{}/".format(sys.argv[-1]))
|
||||
make_server("", int(sys.argv[-1]), main).serve_forever()
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
print('\nThanks!')
|
||||
print("\nThanks!")
|
||||
|
||||
Reference in New Issue
Block a user