Put
Put
@app.put("/posts/{id}")
def update_post(id: int, post: Post):
index = find_index_post(id)
if index == None:
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=f"post with id: {id} does not exist")
post_dict = post.dict()
post_dict['id'] = id
my_posts[index] = post_dict
print(post)
return {"data": post_dict}