Skip to content

Instantly share code, notes, and snippets.

@jinhoyoo
Created September 20, 2017 06:45
Show Gist options
  • Save jinhoyoo/9be62f88a4d31b53720c18a8cc126ea4 to your computer and use it in GitHub Desktop.
Save jinhoyoo/9be62f88a4d31b53720c18a8cc126ea4 to your computer and use it in GitHub Desktop.
aio example.
from aiohttp import web
import json
async def index(request):
return web.Response(text='Hello Aiohttp!')
async def post_todo(request):
body = await request.json()
return web.Response(body=json.dumps(body).encode('utf-8'))
def setup_routes(app):
app.router.add_get('/', index)
app.router.add_post('/post', post_todo, expect_handler = web.Request.json)
app = web.Application()
setup_routes(app)
web.run_app(app, host='127.0.0.1', port=8080)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment