Created
September 20, 2017 06:45
-
-
Save jinhoyoo/9be62f88a4d31b53720c18a8cc126ea4 to your computer and use it in GitHub Desktop.
aio example.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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