v0.1.34: Fix URL resolution and JSON parsing errors
Some checks failed
Deploy to GitHub Pages / build (push) Has been cancelled
Deploy to GitHub Pages / deploy (push) Has been cancelled

- Fixed scan URL to use relative 'scan' instead of '/scan' for Home Assistant ingress
- Improved error handling for non-JSON and malformed API responses
- Added better debugging for JSON parsing errors
- Updated version to 0.1.34 in all files

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
paul2212
2026-03-18 18:09:43 +01:00
parent 620e433547
commit c9de6af83b
4 changed files with 29 additions and 7 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.33",
version = "0.1.34",
lifespan=lifespan,
docs_url=None,
redoc_url=None,
@@ -153,14 +153,25 @@ def _ui_html() -> str:
console.log('Starting scan request...');
try {
const response = await fetch('/scan');
const response = await fetch('scan');
if (!response.ok) {
const error = await response.json();
throw new Error(error.detail || `HTTP error! status: ${response.status}`);
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}`);
}
}
const devices = await response.json();
let devices;
try {
devices = await response.json();
} catch (e) {
const text = await response.text();
throw new Error(`Invalid JSON response: ${text}`);
}
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';