project-a18hs5/endpoints/movieapp.post.py

12 lines
369 B
Python

from fastapi import APIRouter, HTTPException
from helpers.movie_helpers import create_movie
router = APIRouter()
@router.post("/movieapp", status_code=201)
async def create_new_movie(movie_data: dict):
try:
new_movie = create_movie(movie_data)
return new_movie
except Exception as e:
raise HTTPException(status_code=400, detail=str(e))