瀏覽代碼

API for AI localization datas

master
Lorenzo Pollutri 10 小時之前
父節點
當前提交
2bb561b6c8
共有 4 個檔案被更改,包括 34 行新增0 行删除
  1. +3
    -0
      .env
  2. +26
    -0
      app.py
  3. +5
    -0
      config_env.py
  4. 二進制
      fastapi-realworld-example-app-master.zip

+ 3
- 0
.env 查看文件

@@ -21,3 +21,6 @@ KEYCLOAK_TOKEN_URL=${KEYCLOAK_PROTOCOL_ENDPOINT}/token

#CORE info
CORE_API_URL=http://localhost:1902

#BLE AI infer CSV
BLE_AI_INFER_CSV=/data/service/ble-ai-localizer/data/infer/infer.csv

+ 26
- 0
app.py 查看文件

@@ -17,6 +17,7 @@ from tempfile import NamedTemporaryFile
from typing import Callable
import base64
from datetime import datetime, timedelta
import csv

from api_utils import api_utils, coerce_methods
from collections import OrderedDict
@@ -191,6 +192,31 @@ async def get_documentation():
return get_swagger_ui_html(openapi_url="/openapi.json", title="docs")


@app.get("/ble-ai/infer", tags=["BLE-AI"])
async def get_ble_ai_infer():
path = config_env.BLE_AI_INFER_CSV
if not os.path.isfile(path):
raise HTTPException(status_code=404, detail="CSV not found")

items = []
with open(path, newline="") as f:
reader = csv.DictReader(f, delimiter=";")
for row in reader:
try:
items.append(
{
"mac": row.get("mac"),
"z": int(row["z"]) if row.get("z") not in (None, "") else None,
"x": int(row["x"]) if row.get("x") not in (None, "") else None,
"y": int(row["y"]) if row.get("y") not in (None, "") else None,
}
)
except (KeyError, ValueError):
continue

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


@app.post("/majortel/call/", tags=["Majortel"])
async def route_call(active_user=Depends(manager),callerNumber=None, calledNumber=None):
try:


+ 5
- 0
config_env.py 查看文件

@@ -22,3 +22,8 @@ MQTT_VERSION = os.getenv("MQTT_VERSION", "mqttv311")
MQTT_STATUS_INTERVAL = int(os.getenv("MQTT_STATUS_INTERVAL", "30"))
MQTT_STALE_AFTER = int(os.getenv("MQTT_STALE_AFTER", "30"))

BLE_AI_INFER_CSV = os.getenv(
"BLE_AI_INFER_CSV",
"/data/service/ble-ai-localizer/data/infer/infer.csv",
)


二進制
fastapi-realworld-example-app-master.zip 查看文件


Loading…
取消
儲存