16 lines
549 B
Python
16 lines
549 B
Python
from fastapi import APIRouter, Depends, HTTPException
|
|
from sqlalchemy.orm import Session
|
|
from typing import List
|
|
from core.database import get_db
|
|
from schemas.ship import ShipSchema
|
|
from helpers.ship_helpers import get_all_ships
|
|
|
|
router = APIRouter()
|
|
|
|
@router.post("/names", status_code=200, response_model=List[ShipSchema])
|
|
async def get_all_ship_details(db: Session = Depends(get_db)):
|
|
"""Return all ships"""
|
|
ships = get_all_ships(db)
|
|
if not ships:
|
|
raise HTTPException(status_code=404, detail="No ships found")
|
|
return ships |