Bladeren bron

Download maps API

download_maps
Lorenzo Pollutri 1 maand geleden
bovenliggende
commit
3a8249f2e8
3 gewijzigde bestanden met toevoegingen van 38 en 0 verwijderingen
  1. +1
    -0
      .env
  2. +32
    -0
      app.py
  3. +5
    -0
      config_env.py

+ 1
- 0
.env Bestand weergeven

@@ -17,3 +17,4 @@ KEYCLOAK_TOKEN_URL=${KEYCLOAK_PROTOCOL_ENDPOINT}/token
#BLE AI infer CSV #BLE AI infer CSV
BLE_AI_INFER_CSV=/data/service/ble-ai-localizer/data/infer/infer.csv BLE_AI_INFER_CSV=/data/service/ble-ai-localizer/data/infer/infer.csv
BLE_AI_META_DIR=/data/service/ble-ai-localizer/data/maps/ BLE_AI_META_DIR=/data/service/ble-ai-localizer/data/maps/
BLE_AI_MAPS_DIR=/data/service/ble-ai-localizer/data/maps

+ 32
- 0
app.py Bestand weergeven

@@ -297,6 +297,38 @@ async def get_ble_ai_metadata(floor: Optional[int] = Query(default=None)):
return {"items": items, "count": len(items)} return {"items": items, "count": len(items)}




@app.get("/ble-ai/maps", tags=["BLE-AI"], dependencies=[Depends(get_current_user)])
async def get_ble_ai_maps():
maps_dir = config_env.BLE_AI_MAPS_DIR
if not os.path.isdir(maps_dir):
raise HTTPException(status_code=404, detail="Maps directory not found")

items = []
for file_name in sorted(os.listdir(maps_dir), key=str.lower):
if not file_name.lower().endswith(".png"):
continue

file_path = os.path.join(maps_dir, file_name)
if not os.path.isfile(file_path):
continue

with open(file_path, "rb") as f:
encoded = base64.b64encode(f.read()).decode("ascii")

items.append(
{
"name": file_name,
"mime_type": "image/png",
"content_base64": encoded,
}
)

if not items:
raise HTTPException(status_code=404, detail="No PNG maps found")

return {"items": items, "count": len(items)}


@app.get("/openapi.json/", tags=["Documentation"]) @app.get("/openapi.json/", tags=["Documentation"])
async def get_open_api_endpoint(): async def get_open_api_endpoint():
#async def get_open_api_endpoint(current_user: User = Depends(get_current_active_user)): #async def get_open_api_endpoint(current_user: User = Depends(get_current_active_user)):


+ 5
- 0
config_env.py Bestand weergeven

@@ -32,3 +32,8 @@ BLE_AI_META_DIR = os.getenv(
"/data/service/ble-ai-localizer/data/maps/", "/data/service/ble-ai-localizer/data/maps/",
) )


BLE_AI_MAPS_DIR = os.getenv(
"BLE_AI_MAPS_DIR",
"/data/service/ble-ai-localizer/data/maps",
)


Laden…
Annuleren
Opslaan