Spaces:
Sleeping
Sleeping
from fastapi import FastAPI, Depends | |
from sqlalchemy.orm import Session | |
from . import models, schemas, crud | |
app = FastAPI() | |
async def read_users(db: Session = Depends()): | |
users = crud.get_users(db) | |
return {"users": users} | |
async def create_user(user: schemas.UserCreate, db: Session = Depends()): | |
crud.create_user(db, user) | |
return {"message": "User created successfully"} | |
async def read_user(user_id: int, db: Session = Depends()): | |
user = crud.get_user(db, user_id) | |
return {"user": user} | |
async def update_user(user_id: int, user: schemas.UserUpdate, db: Session = Depends()): | |
crud.update_user(db, user_id, user) | |
return {"message": "User updated successfully"} | |
async def create_team(team: schemas.TeamCreate, db: Session = Depends()): | |
crud.create_team(db, team) | |
return {"message": "Team created successfully"} | |
async def read_teams(db: Session = Depends()): | |
teams = crud.get_teams(db) | |
return {"teams": teams} | |
async def read_team(team_id: int, db: Session = Depends()): | |
team = crud.get_team(db, team_id) | |
return {"team": team} |