2016-10-14 20:06:29 -07:00
|
|
|
# Run with python3 simple_server.py PORT
|
|
|
|
|
|
|
|
import asyncio
|
|
|
|
import sys
|
2019-04-24 00:44:42 +03:00
|
|
|
|
2016-10-16 00:50:49 -07:00
|
|
|
import ujson as json
|
2019-04-24 00:44:42 +03:00
|
|
|
import uvloop
|
|
|
|
|
|
|
|
from aiohttp import web
|
|
|
|
|
2016-10-14 20:06:29 -07:00
|
|
|
|
|
|
|
loop = uvloop.new_event_loop()
|
|
|
|
asyncio.set_event_loop(loop)
|
|
|
|
|
2018-12-30 13:18:06 +02:00
|
|
|
|
2016-10-14 20:06:29 -07:00
|
|
|
async def handle(request):
|
2018-12-30 13:18:06 +02:00
|
|
|
return web.Response(
|
|
|
|
body=json.dumps({"test": True}).encode("utf-8"),
|
|
|
|
content_type="application/json",
|
|
|
|
)
|
|
|
|
|
2016-10-14 20:06:29 -07:00
|
|
|
|
|
|
|
app = web.Application(loop=loop)
|
2018-12-30 13:18:06 +02:00
|
|
|
app.router.add_route("GET", "/", handle)
|
2016-10-14 20:06:29 -07:00
|
|
|
|
2016-11-11 22:36:49 +02:00
|
|
|
web.run_app(app, port=sys.argv[1], access_log=None)
|