diff --git a/endpoints/login.post.py b/endpoints/login.post.py index a8ab4aa..0903938 100644 --- a/endpoints/login.post.py +++ b/endpoints/login.post.py @@ -1,37 +1,21 @@ -from fastapi import APIRouter, Depends, HTTPException -from pydantic import BaseModel -from datetime import timedelta -from core.database import get_db +# Entity: FoodImage + +```python +from fastapi import APIRouter, Depends, HTTPException, status from sqlalchemy.orm import Session -from core.auth import verify_password, create_access_token -from models.user import User +from core.database import get_db +from models.food_image import FoodImage +from schemas.food_image import FoodImageSchema, FoodImageCreate +from helpers.food_image_helpers import generate_food_image router = APIRouter() -class UserAuth(BaseModel): - username: str - password: str - -@router.post("/login") -async def login( - user_data: UserAuth, +@router.post("/food-images", status_code=201, response_model=FoodImageSchema) +async def generate_food_photo( + food_details: FoodImageCreate, db: Session = Depends(get_db) ): - """User authentication endpoint""" - user = db.query(User).filter(User.username == user_data.username).first() - - if not user or not verify_password(user_data.password, user.hashed_password): - raise HTTPException(status_code=400, detail="Invalid credentials") - - # Generate token with expiration - access_token = create_access_token( - data={"sub": user.id}, - expires_delta=timedelta(hours=1) - ) - - return { - "access_token": access_token, - "token_type": "bearer", - "user_id": user.id, - "username": user.username - } + """Generate a photo of food based on provided details""" + generated_image = generate_food_image(db, food_details) + return generated_image +``` \ No newline at end of file