Skip to content

Instantly share code, notes, and snippets.

@yuvalherziger
Created January 6, 2022 16:43
Show Gist options
  • Save yuvalherziger/6ecf7226aa14cdf58dd56d295391b8a9 to your computer and use it in GitHub Desktop.
Save yuvalherziger/6ecf7226aa14cdf58dd56d295391b8a9 to your computer and use it in GitHub Desktop.
Sample aiohttp handler
@routes.get("/user/{username}")
async def get_user(request: web.Request):
username = request.match_info.get("username")
if username not in USER_DB:
return web.json_response(
data={"message": "User not found"},
status=404
)
return web.json_response(data=USER_DB.get(username))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment