You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 2671930
Browse filesBrowse the repository at this point in the historyBrowse files
2.7.4: README as a short entrance to the documentation site
Documentation only; the code is the same as 2.7.3.
- README is a minimal entrance: presentation, one example, the site link
and a flat documentation list, with the design notes under Maintaining.
The introduction and its fuller examples move to docs/overview.md.
- Dropped what the site derives or what goes stale: badges, install
commands, Status and License sections, the hand-kept line and example
counts, the dependency tree, the version in the run() banner sample.
- The layers and pytypehintstore are described once in architecture.md,
the widget demo once in types.md.
- examples.md lists the users, bookings and gallery mini-apps, drops the
link to the README and the repeated install blocks.
- Design notes state the theme and stream polling as facts, not plans.
- Links to pytypehint, pytypehintweb and pytypehintstore point to their
documentation sites.
- CHANGELOG headings use "## X.Y.Z - YYYY-MM-DD"; seven dates corrected
to their PyPI upload dates.
- pyproject gains the Documentation URL; Source becomes Repository.
- test_docs_snippets follows the CRUD fragment into docs/overview.md.
Copy file name to clipboardExpand all lines: docs/examples.md
+21-48Lines changed: 21 additions & 48 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,17 +1,17 @@
1
1
# Examples
2
2
3
-
The [documentation](../README.md#documentation) is the technical reference;
4
-
[`examples/`](../examples/) is the hands-on part, and it holds two kinds of file.
3
+
The other pages are the technical reference; [`examples/`](../examples/) is
4
+
the hands-on part, and it holds two kinds of file.
5
5
6
-
**Examples** teach **a single capability** and nothing else: 81 of them, in the
7
-
11 folders of the table below. **Mini-apps** live in [`project/`](../examples/project/) and
8
-
do the opposite — each one combines several capabilities into a small complete
9
-
application, to show how the pieces sit together once there is more than one.
6
+
**Examples** teach **a single capability** and nothing else, grouped in the
7
+
folders of the table below. **Mini-apps** live in
8
+
[`project/`](../examples/project/) and do the opposite — each one combines
9
+
several capabilities into a small complete application, to show how the pieces
10
+
sit together once there is more than one.
10
11
11
-
Both kinds are runnable programs: a file with an `if __name__ == "__main__":`
12
-
guard, which is what the count in the main README means. That is every `.py`
13
-
file here, nothing in the collection is a module that only exists to be
14
-
imported.
12
+
Both kinds are runnable programs: every `.py` file has an
13
+
`if __name__ == "__main__":` guard, and nothing in the collection is a module
14
+
that only exists to be imported.
15
15
16
16
## Running
17
17
@@ -45,19 +45,23 @@ Examples and mini-apps alike serve at <http://127.0.0.1:8000> and block until
45
45
| --- | --- | --- |
46
46
|[`project/todo.py`](../examples/project/todo.py)| one dataclass model reused by three functions, `app_of()` under a prefix, a hand-written route of your own |[types](types.md), [application](router.md)|
47
47
|[`project/todo_stored.py`](../examples/project/todo_stored.py)| the same mini-app whose tasks survive the restart: the dict becomes a store and the model that draws the forms is what the JSON file holds |[types](types.md), [application](router.md)|
48
+
|[`project/users.py`](../examples/project/users.py)| a dataclass with a photo field walking the whole file cycle: upload once, edit with the photo already in place and no byte uploaded again, and a host endpoint serving the stored file |[files](files.md), [prefill](prefill.md), [sdk](sdk.md)|
49
+
|[`project/bookings.py`](../examples/project/bookings.py)| one dataclass that is the whole form and rulebook: a date, two times, an enum, a slider, a toggled note, and a cross-field rule in `__post_init__` that surfaces as a `422` in the form and the API alike |[types](types.md), [prefill](prefill.md)|
50
+
|[`project/gallery.py`](../examples/project/gallery.py)| outputs a CRUD never reaches, drawn inside the modal: an image with its download, a table and streamed lines, with modals that close on their result and modals that do not |[outputs](outputs.md), [streaming](streaming.md), [sdk](sdk.md)|
48
51
49
52
A mini-app is still short enough to read in one sitting, and it is still an
50
53
ordinary FastAPI application: the library contributes an application, never the
51
54
host.
52
55
53
56
## Dependencies
54
57
55
-
Everything works with `pip install func-to-web`, except
58
+
Everything runs with the library alone, except
56
59
[`outputs_optional/`](#outputs-with-optional-dependencies), where each subfolder
57
-
declares its own (`pillow`, `matplotlib`, `pandas`, `polars`, `numpy`), and
58
-
[`project/todo_stored.py`](../examples/project/todo_stored.py), which needs
59
-
[`pytypehintstore`](https://github.com/offerrall/pytypehintstore). None of them
60
-
is required by the library.
60
+
declares its own (`pillow`, `matplotlib`, `pandas`, `polars`, `numpy`);
61
+
[`project/gallery.py`](../examples/project/gallery.py), which needs `pillow` and
62
+
`pandas`; and [`project/todo_stored.py`](../examples/project/todo_stored.py),
63
+
which needs [pytypehintstore](https://offerrall.github.io/pytypehintstore/). None
64
+
of them is required by the library.
61
65
62
66
The examples use fictional data, never access the Internet and write only to
63
67
the system temporary directories, with two deliberate exceptions:
@@ -135,20 +139,13 @@ dependency is imported only inside its own example.
135
139
|`polars/`| polars |`pip install polars`|`table`|
136
140
|`numpy/`| numpy |`pip install numpy`|`table`|
137
141
138
-
Each one is described below. None of these
139
-
libraries is a dependency of FuncToWeb, and none of them appears in
140
-
`pyproject.toml`: install only the one for the example you want to run.
142
+
Each one is described below. None of these libraries is a dependency of
143
+
FuncToWeb: install only the one for the example you want to run.
141
144
142
145
The reference for the outputs contract is in [Outputs](outputs.md).
143
146
144
147
### Image with Pillow
145
148
146
-
Optional dependency: **Pillow**.
147
-
148
-
```bash
149
-
pip install pillow
150
-
```
151
-
152
149
`image.py` draws a square gradient with a frame and a label, and returns
153
150
the `PIL.Image.Image` object unchanged: FuncToWeb recognizes it as an image,
154
151
encodes it as a PNG, and sends it as a data URI inside an `image` output.
0 commit comments