Created
January 6, 2022 16:43
-
-
Save yuvalherziger/6ecf7226aa14cdf58dd56d295391b8a9 to your computer and use it in GitHub Desktop.
Sample aiohttp handler
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
@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