added new http methods and blogposting app

This commit is contained in:
Luxferre
2025-12-25 20:04:24 +02:00
parent c57cdc4fdb
commit 9c2ff12635
4 changed files with 69 additions and 1 deletions
+17
View File
@@ -159,6 +159,8 @@ 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)
- `auth_header(username, password)`: get a dictionary fragment with the corresponding HTTP Basic Auth header according to the username and password
- `url_escape(s)`: escape a string to be used as a part of URL parameters
- `form_encode(params)`: encode a form body dictionary in the `x-www-form-urlencoded` format
- `wget(url, filename='', useragent=None, hdrs={})`: download a file into a local path (returns `(status_code, filename)` tuple)
- `wput(url, file_path, field_name="file", method="POST", format="x-www-form-urlencoded", headers={}, useragent=None)`: upload a file from a local path in the `x-www-form-urlencoded` or JSON format (returns `(status_code, content)` tuple)
@@ -247,6 +249,21 @@ Supported chat commands:
- `/modellist`: list model IDs available for current provider
- `/exit` or `/quit`: exit the chat applet
### `app.blog`
A simple interface to any POST-based blog API that supports HTTP Basic Auth.
Requires the following environment variables to be configured (for T-Deck, use the `/settings.toml` file):
- `BLOG_POST_ENDPOINT`: the full URL to send POST requests to
- `BLOG_POST_USER`: the username to send the requests as
- `BLOG_POST_PASS`: the password for this username
Exports the following functions:
- `blogpost()`: wait for a (multiline) input and send the post,
- `blogpost_str(content)`: post the content in a non-interactive manner.
## FAQ
### Is this an OS shell?