fix: various smaller issues in README

This commit is contained in:
s3lph 2023-10-05 00:10:10 +02:00
parent 5ad9d309b8
commit 0018e11392

View file

@ -42,6 +42,7 @@ look up and return your dynamic content.
```yaml ```yaml
--- ---
api: "0.13" api: "0.13"
api_compatibility: ["14"]
space: My Hackerspace space: My Hackerspace
# This is a plugin invocation # This is a plugin invocation
# with no arguments # with no arguments
@ -60,6 +61,8 @@ sensors:
```json ```json
{ {
"api": "0.13", "api": "0.13",
"api_compatibility": ["14"],
"space": "My Hackerspace",
"state": { "state": {
"open": true, "open": true,
"lastchange": 1575160777, "lastchange": 1575160777,
@ -149,7 +152,7 @@ The content is served "almost-as-is" (apart from the conversion from
YAML to JSON). YAML to JSON).
To learn about how a SpaceAPI response should look like, have a look To learn about how a SpaceAPI response should look like, have a look
at [SpaceAPI: Getting Started][spaceapi-getting-started]. at the [SpaceAPI Website][spaceapi].
### 4. Add Dynamic Content ### 4. Add Dynamic Content
@ -290,9 +293,10 @@ from spaceapi_server import plugins
def lookup_sensor(query, default=None): def lookup_sensor(query, default=None):
# Do something with the query # Do something with the query
result = ... result = ...
# If the loo # If the lookup failed, return a default value
if not result: if not result:
return default or [] return default or []
return result
``` ```
```yaml ```yaml
@ -309,6 +313,5 @@ state: !lookup_sensor
[pypi-bottle]: https://pypi.org/project/bottle/ [pypi-bottle]: https://pypi.org/project/bottle/
[pypi-yaml]: https://pypi.org/project/PyYAML/ [pypi-yaml]: https://pypi.org/project/PyYAML/
[mit]: https://gitlab.com/s3lph/spaceapi-server/blob/main/LICENSE [mit]: https://gitlab.com/s3lph/spaceapi-server/blob/main/LICENSE
[spaceapi-getting-started]: https://spaceapi.io/getting-started/
[jinja]: https://jinja.palletsprojects.com/ [jinja]: https://jinja.palletsprojects.com/
[registry]: https://gitlab.com/s3lph/spaceapi-server/container_registry [registry]: https://gitlab.com/s3lph/spaceapi-server/container_registry