summaryrefslogtreecommitdiff
path: root/Projekt/app/routers/user.py
diff options
context:
space:
mode:
authorRasmus Luha <rasmus.luha@gmail.com>2022-02-06 13:41:11 +0200
committerRasmus Luha <rasmus.luha@gmail.com>2022-02-06 13:41:11 +0200
commit6a6afdbe72c626b01245c9372c9d10be79789bb0 (patch)
treecfdb5aea7538296bad0105c813fce4cd33c19ef5 /Projekt/app/routers/user.py
parent5e19a0569288de21365c61b0db78639880732dd0 (diff)
restrucurring the stucture of the folderstruture --> structure
Diffstat (limited to 'Projekt/app/routers/user.py')
-rw-r--r--Projekt/app/routers/user.py27
1 files changed, 0 insertions, 27 deletions
diff --git a/Projekt/app/routers/user.py b/Projekt/app/routers/user.py
deleted file mode 100644
index 1afe06e..0000000
--- a/Projekt/app/routers/user.py
+++ /dev/null
@@ -1,27 +0,0 @@
-from fastapi import FastAPI, Response, status, HTTPException, Depends, APIRouter
-from .. import models, schemas, utils
-from sqlalchemy.orm import Session
-from ..database import get_db
-
-router = APIRouter(prefix = "/users", tags=["Users"])
-
-@router.post("/", status_code=status.HTTP_201_CREATED, response_model=schemas.UserOut)
-def create_user(user: schemas.UserCreate, db: Session = Depends(get_db)):
- #hash the password <-> user.password
- hashed_password= utils.hash(user.password)
- user.password = hashed_password
-
- new_user = models.User(**user.dict())
- db.add(new_user)
- db.commit() # not sure why have to add+commit, but hey
- db.refresh(new_user) # sama mis SQL: "RESPONDING *"
- return new_user
-
-@router.get("/{id}", response_model=schemas.UserOut)
-def get_user(id: int, db: Session = Depends(get_db)):
- user = db.query(models.User).filter(models.User.id == id).first()
-
- if not user:
- raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=f"User with id: {id} not found")
-
- return user