25 lines
651 B
Python
25 lines
651 B
Python
"""Image endpoints – retrieve photo URLs from listing data."""
|
||
|
||
from fastapi import APIRouter, Depends
|
||
from sqlalchemy import text
|
||
from sqlalchemy.orm import Session
|
||
|
||
from app.config import load_sql
|
||
from app.database import get_db
|
||
|
||
router = APIRouter()
|
||
|
||
|
||
@router.get("/listings/{global_id}/images")
|
||
def get_listing_images(
|
||
global_id: str,
|
||
db: Session = Depends(get_db),
|
||
) -> dict[str, list[str]]:
|
||
"""Return image URLs for a listing."""
|
||
row = db.execute(text(load_sql("listing_images.sql")), {"gid": global_id}).first()
|
||
|
||
if not row or not row.photo_urls:
|
||
return {"images": []}
|
||
|
||
return {"images": list(row.photo_urls)}
|