Ejemplo n.º 1
0
async def add_event(newEvent: schemas.EventCreate = Body(...),
                    db: Session = Depends(get_db)):
    db_event = models.Event(**newEvent.dict())
    db.add(db_event)
    db.commit()
    db.refresh(db_event)
    return "event added successfully"
Ejemplo n.º 2
0
async def add_event(registered: schemas.EventCreate = Body(...),
                    db: Session = Depends(get_db)):
    print(registered)
    db_img = models.Event(**registered.dict())
    db.add(db_img)
    db.commit()
    db.refresh(db_registered)
    return "photo has been added to db!"
Ejemplo n.º 3
0
async def add_event(*,newEvent : schemas.EventCreate = Body(...) , db : Session = Depends(get_db) , token : str = Body(...) , res : Response):
    
    try:
        payload = jwt.decode(token , SECRET_KEY , algorithms=[ALGORITHM])
    except:
        return "TOKEN EXPIRED"
        
    
    username : str = payload.get('sub')
    if username is None:
        raise credentials_exception
    else:
        db_event = models.Event(**newEvent.dict())
        db.add(db_event)
        db.commit()
        db.refresh(db_event)
        return "event added successfully"