17 lines
510 B
Python
17 lines
510 B
Python
from fastapi import APIRouter, Depends, HTTPException
|
|
from sqlalchemy.orm import Session
|
|
from typing import List
|
|
from core.database import get_db
|
|
from helpers.ship_helpers import get_ship_names
|
|
|
|
router = APIRouter()
|
|
|
|
@router.post("/names", status_code=200, response_model=List[str])
|
|
async def get_names(
|
|
db: Session = Depends(get_db)
|
|
):
|
|
"""Get all ship names"""
|
|
names = get_ship_names(db)
|
|
if not names:
|
|
raise HTTPException(status_code=404, detail="No ship names found")
|
|
return names |