浏览代码

Download maps API

download_maps
Lorenzo Pollutri 1 个月前
父节点
当前提交
3a8249f2e8
共有 3 个文件被更改,包括 38 次插入0 次删除
  1. +1
    -0
      .env
  2. +32
    -0
      app.py
  3. +5
    -0
      config_env.py

+ 1
- 0
.env 查看文件

@@ -17,3 +17,4 @@ KEYCLOAK_TOKEN_URL=${KEYCLOAK_PROTOCOL_ENDPOINT}/token
#BLE AI 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_MAPS_DIR=/data/service/ble-ai-localizer/data/maps

+ 32
- 0
app.py 查看文件

@@ -297,6 +297,38 @@ async def get_ble_ai_metadata(floor: Optional[int] = Query(default=None)):
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"])
async def get_open_api_endpoint():
#async def get_open_api_endpoint(current_user: User = Depends(get_current_active_user)):


+ 5
- 0
config_env.py 查看文件

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

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


正在加载...
取消
保存