This commit is contained in:
paul2212
2026-03-18 18:41:01 +01:00
parent c9de6af83b
commit 1243e1f8c5
4 changed files with 23 additions and 15 deletions

View File

@@ -77,7 +77,7 @@ async def lifespan(app: FastAPI): # noqa: ARG001
app = FastAPI(
title="Fichero Printer API",
description="REST API for the Fichero D11s (AiYin) thermal label printer.",
version = "0.1.34",
version = "0.1.35",
lifespan=lifespan,
docs_url=None,
redoc_url=None,
@@ -155,24 +155,21 @@ def _ui_html() -> str:
try {
const response = await fetch('scan');
if (!response.ok) {
try {
const error = await response.json();
throw new Error(error.detail || `HTTP error! status: ${response.status}`);
} catch (e) {
const text = await response.text();
throw new Error(`HTTP error! status: ${response.status}, response: ${text}`);
}
}
let devices;
let responseData;
try {
devices = await response.json();
responseData = await response.json();
} catch (e) {
const text = await response.text();
throw new Error(`Invalid JSON response: ${text}`);
}
if (!response.ok) {
const errorDetail = responseData.detail || `HTTP error! status: ${response.status}`;
throw new Error(errorDetail);
}
const devices = responseData;
if (devices.length === 0) {
resultsEl.textContent = '📡 No BLE devices found.\n\nTroubleshooting tips:\n- Make sure your printer is powered on\n- Ensure Bluetooth is enabled on this device\n- Bring the printer closer (within 5 meters)\n- Try restarting the printer';
} else {