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