2016-10-15 04:06:29 +01:00
|
|
|
# Run with python3 simple_server.py PORT
|
|
|
|
|
|
|
|
from aiohttp import web
|
|
|
|
import asyncio
|
|
|
|
import sys
|
|
|
|
import uvloop
|
2016-10-16 08:50:49 +01:00
|
|
|
import ujson as json
|
2016-10-15 04:06:29 +01:00
|
|
|
|
|
|
|
loop = uvloop.new_event_loop()
|
|
|
|
asyncio.set_event_loop(loop)
|
|
|
|
|
|
|
|
async def handle(request):
|
2016-10-16 08:50:49 +01: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)
|
|
|
|
app.router.add_route('GET', '/', handle)
|
|
|
|
|
|
|
|
web.run_app(app, port=sys.argv[1])
|