pyganini 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyganini-0.1.0/LICENSE +200 -0
- pyganini-0.1.0/PKG-INFO +380 -0
- pyganini-0.1.0/README.md +354 -0
- pyganini-0.1.0/pyproject.toml +89 -0
- pyganini-0.1.0/pyproject.toml.orig +75 -0
- pyganini-0.1.0/src/pyganini/__init__.py +94 -0
- pyganini-0.1.0/src/pyganini/__main__.py +5 -0
- pyganini-0.1.0/src/pyganini/_assets.py +1461 -0
- pyganini-0.1.0/src/pyganini/_cli.py +769 -0
- pyganini-0.1.0/src/pyganini/_config.py +52 -0
- pyganini-0.1.0/src/pyganini/_declarations.py +848 -0
- pyganini-0.1.0/src/pyganini/_dispatch.py +2795 -0
- pyganini-0.1.0/src/pyganini/_dispatch_generation.py +1472 -0
- pyganini-0.1.0/src/pyganini/_filesystem.py +1041 -0
- pyganini-0.1.0/src/pyganini/_generation.py +676 -0
- pyganini-0.1.0/src/pyganini/_inspection.py +1998 -0
- pyganini-0.1.0/src/pyganini/_navigation.py +576 -0
- pyganini-0.1.0/src/pyganini/_paths.py +165 -0
- pyganini-0.1.0/src/pyganini/_render.py +549 -0
- pyganini-0.1.0/src/pyganini/_route_graph.py +4924 -0
- pyganini-0.1.0/src/pyganini/_template_references.py +898 -0
- pyganini-0.1.0/src/pyganini/_url_binding.py +81 -0
- pyganini-0.1.0/src/pyganini/_url_generation.py +1739 -0
- pyganini-0.1.0/src/pyganini/browser/__init__.py +164 -0
- pyganini-0.1.0/src/pyganini/browser/pyganini-sse-event.js +27 -0
- pyganini-0.1.0/src/pyganini/browser/pyganini-template-inspector.js +482 -0
- pyganini-0.1.0/src/pyganini/csrf.py +341 -0
- pyganini-0.1.0/src/pyganini/hx.py +98 -0
- pyganini-0.1.0/src/pyganini/py.typed +0 -0
- pyganini-0.1.0/src/pyganini/request_data.py +319 -0
- pyganini-0.1.0/src/pyganini/sse.py +90 -0
pyganini-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works, alongside or as an addendum
|
|
119
|
+
to the NOTICE text from the Work, provided that such additional
|
|
120
|
+
attribution notices cannot be construed as modifying the License.
|
|
121
|
+
|
|
122
|
+
You may add Your own copyright statement to Your modifications and
|
|
123
|
+
may provide additional or different license terms and conditions
|
|
124
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
125
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
126
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
127
|
+
the conditions stated in this License.
|
|
128
|
+
|
|
129
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
130
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
131
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
132
|
+
this License, without any additional terms or conditions.
|
|
133
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
134
|
+
the terms of any separate license agreement you may have executed
|
|
135
|
+
with Licensor regarding such Contributions.
|
|
136
|
+
|
|
137
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
138
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
139
|
+
except as required for reasonable and customary use in describing the
|
|
140
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
141
|
+
|
|
142
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
143
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
144
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
145
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
146
|
+
implied, including, without limitation, any warranties or conditions
|
|
147
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
148
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
149
|
+
appropriateness of using or redistributing the Work and assume any
|
|
150
|
+
risks associated with Your exercise of permissions under this License.
|
|
151
|
+
|
|
152
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
153
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
154
|
+
unless required by applicable law (such as deliberate and grossly
|
|
155
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
156
|
+
liable to You for damages, including any direct, indirect, special,
|
|
157
|
+
incidental, or consequential damages of any character arising as a
|
|
158
|
+
result of this License or out of the use or inability to use the
|
|
159
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
160
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
161
|
+
other commercial damages or losses), even if such Contributor
|
|
162
|
+
has been advised of the possibility of such damages.
|
|
163
|
+
|
|
164
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
165
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
166
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
167
|
+
or other liability obligations and/or rights consistent with this
|
|
168
|
+
License. However, in accepting such obligations, You may act only
|
|
169
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
170
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
171
|
+
defend, and hold each Contributor harmless for any liability
|
|
172
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
173
|
+
of your accepting any such warranty or additional liability.
|
|
174
|
+
|
|
175
|
+
END OF TERMS AND CONDITIONS
|
|
176
|
+
|
|
177
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
178
|
+
|
|
179
|
+
To apply the Apache License to your work, attach the following
|
|
180
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
181
|
+
replaced with your own identifying information. (Don't include
|
|
182
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
183
|
+
comment syntax for the file format. We also recommend that a
|
|
184
|
+
file or class name and description of purpose be included on the
|
|
185
|
+
same "printed page" as the copyright notice for easier
|
|
186
|
+
identification within third-party archives.
|
|
187
|
+
|
|
188
|
+
Copyright 2026 Toly Pochkin.
|
|
189
|
+
|
|
190
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
191
|
+
you may not use this file except in compliance with the License.
|
|
192
|
+
You may obtain a copy of the License at
|
|
193
|
+
|
|
194
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
195
|
+
|
|
196
|
+
Unless required by applicable law or agreed to in writing, software
|
|
197
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
198
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
199
|
+
See the License for the specific language governing permissions and
|
|
200
|
+
limitations under the License.
|
pyganini-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pyganini
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Server-first, HTML-first, HTMX-native Python web framework
|
|
5
|
+
Author: Toly Pochkin
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Environment :: Web Environment
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
14
|
+
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
15
|
+
Classifier: Typing :: Typed
|
|
16
|
+
Requires-Dist: anyio>=4.14.2,<4.15
|
|
17
|
+
Requires-Dist: jinja2>=3.1.6,<4
|
|
18
|
+
Requires-Dist: python-multipart>=0.0.32,<0.0.33
|
|
19
|
+
Requires-Dist: starlette>=1.6.0,<1.7
|
|
20
|
+
Requires-Python: >=3.13
|
|
21
|
+
Project-URL: Homepage, https://github.com/mobiletoly/pyganini
|
|
22
|
+
Project-URL: Repository, https://github.com/mobiletoly/pyganini
|
|
23
|
+
Project-URL: Issues, https://github.com/mobiletoly/pyganini/issues
|
|
24
|
+
Project-URL: Documentation, https://github.com/mobiletoly/pyganini/tree/main/docs/user
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
|
|
27
|
+
# Pyganini
|
|
28
|
+
|
|
29
|
+
[](https://github.com/mobiletoly/pyganini/actions/workflows/ci.yml)
|
|
30
|
+
[](https://github.com/mobiletoly/pyganini/releases/latest)
|
|
31
|
+
[](LICENSE)
|
|
32
|
+
|
|
33
|
+
Pyganini is a server-first Python web framework for HTML applications. You
|
|
34
|
+
organize routes as Python packages, render Jinja templates, and use generated
|
|
35
|
+
URL helpers instead of handwritten paths. Pyganini supports visible HTMX
|
|
36
|
+
interactions while your application keeps control of Starlette or FastAPI,
|
|
37
|
+
middleware, data access, and deployment.
|
|
38
|
+
|
|
39
|
+
If Pyganini helps your project, please [star the repository](https://github.com/mobiletoly/pyganini).
|
|
40
|
+
|
|
41
|
+
## Why Pyganini?
|
|
42
|
+
|
|
43
|
+
Server-rendered applications often accumulate route tables, string URLs, and
|
|
44
|
+
rendering conventions that drift apart. Pyganini derives those surfaces from
|
|
45
|
+
one filesystem route tree.
|
|
46
|
+
|
|
47
|
+
- Route packages keep handlers, templates, layouts, and middleware together.
|
|
48
|
+
- Generation produces a deterministic Starlette router and typed URL helpers.
|
|
49
|
+
- `pyganini check` catches stale generated files and invalid route source.
|
|
50
|
+
- Jinja stays focused on HTML, including visible `hx-*` attributes.
|
|
51
|
+
- Your application owns its server, middleware, sessions, persistence, and
|
|
52
|
+
deployment policy.
|
|
53
|
+
|
|
54
|
+
Pyganini supports CPython 3.13 and newer.
|
|
55
|
+
|
|
56
|
+
## Try a Complete App First
|
|
57
|
+
|
|
58
|
+
The [full-feature example](examples/full_feature) is a contact directory with
|
|
59
|
+
nested layouts, dynamic pages, forms, HTMX fragments, route kits, navigation,
|
|
60
|
+
assets, browser helpers, and generated error pages.
|
|
61
|
+
|
|
62
|
+
```text
|
|
63
|
+
git clone https://github.com/mobiletoly/pyganini.git
|
|
64
|
+
cd pyganini/examples/full_feature
|
|
65
|
+
uv sync --locked --all-groups --python 3.14
|
|
66
|
+
uv run --locked uvicorn app.main:app --host 127.0.0.1 --port 8000
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Open [http://127.0.0.1:8000](http://127.0.0.1:8000).
|
|
70
|
+
|
|
71
|
+
## Quick Start
|
|
72
|
+
|
|
73
|
+
This small application serves one page through an application-owned Starlette
|
|
74
|
+
host. Install Pyganini, Starlette, and Uvicorn in a new directory:
|
|
75
|
+
|
|
76
|
+
```text
|
|
77
|
+
mkdir hello-pyganini
|
|
78
|
+
cd hello-pyganini
|
|
79
|
+
mkdir -p app/routes
|
|
80
|
+
touch app/__init__.py app/routes/__init__.py
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Create `pyproject.toml`:
|
|
84
|
+
|
|
85
|
+
```toml
|
|
86
|
+
[project]
|
|
87
|
+
name = "hello-pyganini"
|
|
88
|
+
version = "0.0.0"
|
|
89
|
+
requires-python = ">=3.13"
|
|
90
|
+
dependencies = [
|
|
91
|
+
"pyganini==0.1.0",
|
|
92
|
+
"starlette>=1.6.0,<1.7",
|
|
93
|
+
"uvicorn>=0.52.4,<0.53",
|
|
94
|
+
]
|
|
95
|
+
|
|
96
|
+
[tool.pyganini]
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Add the root route in `app/routes/route.py`:
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
from pyganini import route
|
|
103
|
+
|
|
104
|
+
from .handlers import page
|
|
105
|
+
|
|
106
|
+
Route = route(page=page, template="page.jinja")
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Return a page from `app/routes/handlers.py`:
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
from pyganini import Page, PageMetadata
|
|
113
|
+
from starlette.requests import Request
|
|
114
|
+
|
|
115
|
+
from app._pyganini.urls import urls
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def page(_: Request) -> Page:
|
|
119
|
+
return Page(
|
|
120
|
+
context={"home_url": urls.root.path},
|
|
121
|
+
metadata=PageMetadata(title="Hello from Pyganini"),
|
|
122
|
+
layout={"product": "Pyganini"},
|
|
123
|
+
)
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Add `app/routes/page.jinja`:
|
|
127
|
+
|
|
128
|
+
```html
|
|
129
|
+
<main>
|
|
130
|
+
<h1>Hello from Pyganini</h1>
|
|
131
|
+
<p>The generated URL for this page is <code>{{ home_url }}</code>.</p>
|
|
132
|
+
</main>
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Create an empty layout marker at `app/routes/layout.py`, then add
|
|
136
|
+
`app/routes/layout.jinja`:
|
|
137
|
+
|
|
138
|
+
```html
|
|
139
|
+
<!doctype html>
|
|
140
|
+
<html lang="en">
|
|
141
|
+
<head>
|
|
142
|
+
<meta charset="utf-8">
|
|
143
|
+
<title>{{ metadata.title }}</title>
|
|
144
|
+
</head>
|
|
145
|
+
<body>
|
|
146
|
+
<header>{{ layout.product }}</header>
|
|
147
|
+
{{ child }}
|
|
148
|
+
</body>
|
|
149
|
+
</html>
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Mount the generated router from `app/main.py`:
|
|
153
|
+
|
|
154
|
+
```python
|
|
155
|
+
from starlette.applications import Starlette
|
|
156
|
+
from starlette.routing import Mount
|
|
157
|
+
|
|
158
|
+
from app._pyganini.asgi import router
|
|
159
|
+
|
|
160
|
+
app = Starlette(routes=[Mount("/", app=router)])
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Generate the router and URL helpers before importing `app.main`, then check and
|
|
164
|
+
run the application:
|
|
165
|
+
|
|
166
|
+
```text
|
|
167
|
+
uv sync
|
|
168
|
+
uv run pyganini generate
|
|
169
|
+
uv run pyganini check
|
|
170
|
+
uv run uvicorn app.main:app --host 127.0.0.1 --port 8000
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Open [http://127.0.0.1:8000](http://127.0.0.1:8000). Continue with
|
|
174
|
+
[Getting Started](docs/user/getting-started.md) to add a dynamic user page and
|
|
175
|
+
inspect the generated route graph.
|
|
176
|
+
|
|
177
|
+
## What Pyganini Gives You
|
|
178
|
+
|
|
179
|
+
### Build pages from the filesystem
|
|
180
|
+
|
|
181
|
+
Each package below `app/routes` maps to a URL segment. A route declaration
|
|
182
|
+
connects a handler to its adjacent Jinja template. `layout.py` and
|
|
183
|
+
`layout.jinja` mark layout ownership for that route subtree.
|
|
184
|
+
|
|
185
|
+
### Generate checked application interfaces
|
|
186
|
+
|
|
187
|
+
`pyganini generate` writes the router and typed URL tree below
|
|
188
|
+
`app/_pyganini`. `pyganini check` rebuilds the expected bytes in memory and
|
|
189
|
+
reports missing, stale, or invalid output without changing files.
|
|
190
|
+
|
|
191
|
+
### Keep HTMX in the template
|
|
192
|
+
|
|
193
|
+
Templates use ordinary `hx-get`, `hx-post`, `hx-target`, and `hx-swap`
|
|
194
|
+
attributes. Generated URL values remove string paths without hiding the
|
|
195
|
+
browser interaction.
|
|
196
|
+
|
|
197
|
+
### Inspect before you run
|
|
198
|
+
|
|
199
|
+
The CLI can list routes, show layout chains, explain one request path, find
|
|
200
|
+
template route references, and report render units from source. These commands
|
|
201
|
+
do not import application modules.
|
|
202
|
+
|
|
203
|
+
### Own the application boundary
|
|
204
|
+
|
|
205
|
+
Pyganini generates a Starlette router. Your application decides whether to
|
|
206
|
+
serve it through Starlette or mount it in FastAPI. It also owns authentication,
|
|
207
|
+
sessions, storage, middleware, static serving, and process management.
|
|
208
|
+
|
|
209
|
+
## How Pyganini Apps Are Shaped
|
|
210
|
+
|
|
211
|
+
A larger application can grow from the same route tree:
|
|
212
|
+
|
|
213
|
+
```text
|
|
214
|
+
pyproject.toml
|
|
215
|
+
app/
|
|
216
|
+
__init__.py
|
|
217
|
+
main.py
|
|
218
|
+
routes/
|
|
219
|
+
__init__.py
|
|
220
|
+
route.py
|
|
221
|
+
handlers.py
|
|
222
|
+
layout.py
|
|
223
|
+
layout.jinja
|
|
224
|
+
page.jinja
|
|
225
|
+
users/
|
|
226
|
+
__init__.py
|
|
227
|
+
route.py
|
|
228
|
+
handlers.py
|
|
229
|
+
page.jinja
|
|
230
|
+
by_user_id/
|
|
231
|
+
__init__.py
|
|
232
|
+
route.py
|
|
233
|
+
handlers.py
|
|
234
|
+
page.jinja
|
|
235
|
+
shared/
|
|
236
|
+
reports/
|
|
237
|
+
__init__.py
|
|
238
|
+
page.jinja
|
|
239
|
+
_pyganini/
|
|
240
|
+
.pyganini-root
|
|
241
|
+
__init__.py
|
|
242
|
+
asgi.py
|
|
243
|
+
urls.py
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
Static package names map underscores to URL hyphens. A package named
|
|
247
|
+
`by_user_id` creates `{user_id}` in the path. Each `route.py` contains one
|
|
248
|
+
static `Route` declaration:
|
|
249
|
+
|
|
250
|
+
```python
|
|
251
|
+
from pyganini import action, fragment_route, route
|
|
252
|
+
|
|
253
|
+
from .handlers import fragment_table, page, post_save
|
|
254
|
+
|
|
255
|
+
Route = route(
|
|
256
|
+
page=page,
|
|
257
|
+
template="page.jinja",
|
|
258
|
+
fragments=(fragment_route("/table", fragment_table, template="table.jinja"),),
|
|
259
|
+
actions=(action("POST", "/save", post_save, template="form.jinja"),),
|
|
260
|
+
)
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
Pyganini reads declarations without importing application code. Generation
|
|
264
|
+
writes one live route graph for dispatch, URL helpers, checks, and inspection.
|
|
265
|
+
Application code imports generated products after generation:
|
|
266
|
+
|
|
267
|
+
```python
|
|
268
|
+
from app._pyganini.asgi import router
|
|
269
|
+
from app._pyganini.urls import urls
|
|
270
|
+
|
|
271
|
+
user_path = urls.users.by_user_id("42").path
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
Pages inherit layouts from their route ancestry. Fragments render without page
|
|
275
|
+
layouts. Route kits let several live route owners share typed handlers and
|
|
276
|
+
templates while each owner keeps its path and URL surface. Mounted route
|
|
277
|
+
subtrees provide filesystem-shaped reuse with explicit selection.
|
|
278
|
+
|
|
279
|
+
Run source inspection from the application root:
|
|
280
|
+
|
|
281
|
+
```text
|
|
282
|
+
uv run pyganini routes list
|
|
283
|
+
uv run pyganini routes layouts
|
|
284
|
+
uv run pyganini routes explain /users/42
|
|
285
|
+
uv run pyganini routes refs
|
|
286
|
+
uv run pyganini routes render-units
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
The generated router can serve on its own or mount below Starlette or FastAPI.
|
|
290
|
+
Pyganini runs asynchronous handlers on the event loop and synchronous handlers
|
|
291
|
+
in an AnyIO worker thread.
|
|
292
|
+
|
|
293
|
+
## More Examples
|
|
294
|
+
|
|
295
|
+
- [Full-feature contact directory](examples/full_feature) combines the public
|
|
296
|
+
route, rendering, navigation, HTMX, asset, SSE, browser, and error surfaces.
|
|
297
|
+
- [React island](examples/react_island) mounts one application-owned React
|
|
298
|
+
editor inside a server-rendered page.
|
|
299
|
+
- [Svelte island](examples/svelte_island) mounts the same bounded interaction
|
|
300
|
+
with Svelte while keeping the server route model unchanged.
|
|
301
|
+
|
|
302
|
+
## Documentation
|
|
303
|
+
|
|
304
|
+
- [Getting Started](docs/user/getting-started.md) builds a two-page application
|
|
305
|
+
with a shared layout, a dynamic route, generated URL helpers, route
|
|
306
|
+
inspection, and an application-owned Starlette host.
|
|
307
|
+
- [Installation](docs/user/installation.md) covers Python support, package
|
|
308
|
+
installation, runtime dependencies, and host ownership.
|
|
309
|
+
- [Project layout](docs/user/project-layout.md) covers the application marker,
|
|
310
|
+
fixed source and generated paths, and file ownership.
|
|
311
|
+
- [Command line](docs/user/cli.md) covers generation, non-writing checks, root
|
|
312
|
+
selection, output, diagnostics, and exit codes.
|
|
313
|
+
- [Assets](docs/user/assets.md) covers final build projection, fingerprinted
|
|
314
|
+
output, generated lookup, commands, cleanup, host composition, and
|
|
315
|
+
development flow.
|
|
316
|
+
- [Bounded client islands](docs/user/client-islands.md) covers explicit
|
|
317
|
+
application-owned roots, lifecycle cleanup, JSON policy, and build ownership.
|
|
318
|
+
- [Route inspection](docs/user/route-inspection.md) covers source-only
|
|
319
|
+
declaration, implementation, navigation, mounted-selection, layout, and
|
|
320
|
+
error-render evidence.
|
|
321
|
+
- [Routes](docs/user/routes.md) covers live route packages, declarations, path
|
|
322
|
+
mapping, layouts, and static validation.
|
|
323
|
+
- [Route middleware](docs/user/middleware.md) covers live route-tree middleware,
|
|
324
|
+
ordering, mounted-owner scope, diagnostics, and host boundaries.
|
|
325
|
+
- [Error composition](docs/user/errors.md) covers the optional generated-route
|
|
326
|
+
error callback, response contracts, and host ownership.
|
|
327
|
+
- [Route kits](docs/user/route-kits.md) covers shared implementations, typed kit
|
|
328
|
+
values, owner-specific URLs, shared templates, and invocation boundaries.
|
|
329
|
+
- [Mounted route subtrees](docs/user/mounted-routes.md) covers reusable
|
|
330
|
+
filesystem-shaped source trees, exact selection, owner-bound URLs, and
|
|
331
|
+
mounted layout order.
|
|
332
|
+
- [Navigation](docs/user/navigation.md) covers request-local trails, dynamic
|
|
333
|
+
labels, typed destinations, alternate keys, Back, return safety, and mounted
|
|
334
|
+
ownership.
|
|
335
|
+
- [Generated URL interfaces](docs/user/urls.md) covers typed route-shaped paths,
|
|
336
|
+
dynamic values, explicit base paths, and query and request-context
|
|
337
|
+
boundaries.
|
|
338
|
+
- [Rendering and responses](docs/user/rendering.md) covers Jinja environments,
|
|
339
|
+
pages, layouts, fragments, render values, and direct Starlette responses.
|
|
340
|
+
- [Server-Sent Event helpers](docs/user/sse.md) covers UTF-8 wire framing,
|
|
341
|
+
comments, reconnection headers, Starlette streaming, and application-owned
|
|
342
|
+
operational policy.
|
|
343
|
+
- [Browser helpers](docs/user/browser.md) covers the optional fixed-resource
|
|
344
|
+
app, named SSE event swaps, template overlay delivery, explicit mounting,
|
|
345
|
+
and cache revalidation.
|
|
346
|
+
- [Template inspection](docs/user/template-inspection.md) covers typed
|
|
347
|
+
development modes, render markers, explicit Jinja call blocks, and the
|
|
348
|
+
optional browser overlay.
|
|
349
|
+
- [HTMX and async forms](docs/user/htmx.md) covers visible attributes, generated
|
|
350
|
+
URL values, header helpers, Starlette form parsing, uploads, and validation.
|
|
351
|
+
- [CSRF helpers](docs/user/csrf.md) covers the optional signed-cookie helper,
|
|
352
|
+
visible form and HTMX values, validation ordering, and application-owned
|
|
353
|
+
policy.
|
|
354
|
+
|
|
355
|
+
## Contributing
|
|
356
|
+
|
|
357
|
+
The repository uses uv 0.12.3 and Python 3.14 for development while retaining
|
|
358
|
+
Python 3.13 compatibility:
|
|
359
|
+
|
|
360
|
+
```text
|
|
361
|
+
uv python install 3.13 3.14
|
|
362
|
+
uv lock --check
|
|
363
|
+
uv sync --locked --all-groups --python 3.14
|
|
364
|
+
uv run --locked --python 3.14 ruff format --check .
|
|
365
|
+
uv run --locked --python 3.14 ruff check .
|
|
366
|
+
uv run --locked --python 3.14 mypy src/pyganini
|
|
367
|
+
uv run --locked --python 3.14 pyright src/pyganini
|
|
368
|
+
uv run --locked --python 3.14 pytest -q tests/test_csrf_typing.py tests/test_sse_typing.py tests/test_assets.py::test_generated_asset_consumers_are_checked_by_both_type_checkers
|
|
369
|
+
uv run --locked --python 3.14 pytest
|
|
370
|
+
uv sync --locked --all-groups --python 3.13
|
|
371
|
+
uv run --locked --python 3.13 pytest
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
Maintainer architecture records live under [`docs/arch`](docs/arch). The
|
|
375
|
+
[release guide](docs/releasing.md) records candidate and trusted-publisher
|
|
376
|
+
steps.
|
|
377
|
+
|
|
378
|
+
## License
|
|
379
|
+
|
|
380
|
+
Pyganini is licensed under the [Apache License 2.0](LICENSE).
|