Files
Stijnvandenbroek c908d96921 feat: separate sql
2026-03-06 14:26:20 +00:00

25 lines
651 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""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)}