From 1243e1f8c5f99590a8fa7b9162c8247e7011d4e0 Mon Sep 17 00:00:00 2001 From: paul2212 Date: Wed, 18 Mar 2026 18:41:01 +0100 Subject: [PATCH] 0.1.35 --- fichero_printer/CHANGELOG.md | 11 +++++++++++ fichero_printer/config.yaml | 2 +- fichero_printer/fichero/api.py | 23 ++++++++++------------- pyproject.toml | 2 +- 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/fichero_printer/CHANGELOG.md b/fichero_printer/CHANGELOG.md index 33406b0..859fcdf 100644 --- a/fichero_printer/CHANGELOG.md +++ b/fichero_printer/CHANGELOG.md @@ -5,6 +5,17 @@ All notable changes to this project are documented in this file. The format is based on Keep a Changelog and this project uses Semantic Versioning. +## [0.1.35] - 2026-03-18 + +### Fixed +- **Web UI**: Fixed "body stream already read" error by reading response body only once. +- **Web UI**: Improved response handling to avoid double-reading response stream. +- **Web UI**: Better error messages for server-side 500 errors from scan endpoint. + +### Changed +- **Web UI**: Refactored response handling to use single response.read() call. +- **Web UI**: Enhanced error display for server-side scan failures. + ## [0.1.34] - 2026-03-18 ### Fixed diff --git a/fichero_printer/config.yaml b/fichero_printer/config.yaml index d6ca277..f915f67 100644 --- a/fichero_printer/config.yaml +++ b/fichero_printer/config.yaml @@ -1,5 +1,5 @@ name: "Fichero Printer" -version: "0.1.34" +version: "0.1.35" slug: "fichero_printer" description: "REST API for the Fichero D11s (AiYin) thermal label printer over Bluetooth" url: "https://git.leuschner.dev/Tobias/Fichero" diff --git a/fichero_printer/fichero/api.py b/fichero_printer/fichero/api.py index c55584c..df5a3c6 100644 --- a/fichero_printer/fichero/api.py +++ b/fichero_printer/fichero/api.py @@ -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 { diff --git a/pyproject.toml b/pyproject.toml index b71aded..9ce0606 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "fichero-printer" -version = "0.1.34" +version = "0.1.35" description = "Web GUI, Python CLI, and protocol documentation for the Fichero D11s thermal label printer." readme = "README.md" requires-python = ">=3.10"