implemented deck.http

This commit is contained in:
Luxferre
2025-12-23 19:03:18 +02:00
parent f64d9b096c
commit c95c1dd702
3 changed files with 65 additions and 3 deletions
+14 -2
View File
@@ -105,7 +105,9 @@ Various hardware information. May be expanded in the future.
Exports the following functions:
- `board_id()`: get the board ID (e.g. `lilygo_tdeck` for T-Deck/T-Deck Plus), or `emulated` if it's not run on a CircuitPython device
- `battery_v()`: (T-Deck-specific) get the current battery voltage
- `battery_v()`: (T-Deck-specific) get the current battery voltage (or 0 if running in an emulated environment)
Also, this module exposes the `REAL_HW` variable to detect whether the code is running on a real hardware in the CircuitPython environment.
### `deck.net`
@@ -138,6 +140,16 @@ except:
import requests
```
### `deck.http`
High-level HTTP client library.
Exports the following functions:
- `http_set_ua(ua_str='Mozilla/5.0')`: set a default HTTP user agent string
- `http_fetch(url, useragent=None, hdrs={})`: fetch text content from a URL into a string (returns `(status_code, content)` tuple)
- `wget(url, filename='', useragent=None, hdrs={})`: download a file into a local path (returns `(status_code, filename)` tuple)
### `deck.llm`
A helper library for interaction with remote LLM (large language model) endpoints that expose OpenAI-compatible API. As of now, it only exports a single class, `LLMChat`, to encapsulate all the interaction.
@@ -254,7 +266,7 @@ You can start it with `from tdeckboot import *` to give it the same extended cap
The foundational module set is going to at least include high-level capabilities for:
- exposing low-level socket and HTTP APIs (done),
- high-level HTTP APIs,
- high-level HTTP APIs (partially done),
- high-level LLM APIs (partially done),
- date and time informaion (done),
- file system manipulation (done),