Skip to content

Instantly share code, notes, and snippets.

@tebeka
Created November 23, 2023 06:38
Show Gist options
  • Save tebeka/43d2c56bfe07e1b2dc78efd2b58fd587 to your computer and use it in GitHub Desktop.
Save tebeka/43d2c56bfe07e1b2dc78efd2b58fd587 to your computer and use it in GitHub Desktop.
@app.get("/users/{user_id}")
def get_user(user_id):
user = app.state.db.get_user(user_id)
if user is None:
raise HTTPException(HTTPStatus.NOT_FOUND)
data = json.dumps(asdict(user))
return Response(data, media_type='application/json')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment