Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions index.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class User(SQLModel, table=True):
@app.get("/")
async def root():
# TODO include the user's name if they are logged in
return {"message": "Hello {}".format("World")}
return {"message": "Hello {self.name}".format("World")}


@app.post("/user")
Expand All @@ -33,15 +33,21 @@ async def create_new_user(*, user: User):
session.add(user)
session.commit()
# TODO return the User ID
return {"message": "User created"}
return user.id

# return {"message": "User created"}

@app.get("/user/{id}")
async def get_user(id: int):
with Session(engine) as session:
# TODO return the user based on the ID (and an error if not)
# I will first create an if statement that check if the id of the
# user is equal to the id we have else return an error if it doesnt exist
statement = select(User).where(User.name == id)
user = session.exec(statement).first()
return {"user": user}
if statement:
return {"user": User.name}
else:
return "User not found"

@app.get("/api/webhooks")
async def handle_hook(*, event: Any):
Expand Down