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 }}
This repository was archived by the owner on Nov 10, 2026. It is now read-only.
Repository navigation
Commit 195df0d
Browse filesBrowse the repository at this point in the historyBrowse files
<!--
Before submitting:
- Read CONTRIBUTING.md for workflow
- Read AGENTS.md for architecture (especially if AI-generated)
Air's design principles: semantic APIs with clear docstrings,
concise docs mindful of context window sizes, max readability,
less code is better, zero config is ideal. — airwebframework.org
-->
## What
This is a collection of doc improvements and edits from the point of
view of a new user.
## Pattern
N/A
## Reviewer Focus
- Consistency was applied to the examples
- Updated the examples
- Fixed some broken examples
- Added an alternate way to pass reserved words.
## Checklist
- [X] Diff contains only changes for this task — no unrelated
refactoring or cleanup
- [ ] Addresses exactly one issue or feature
- [ ] New or changed behavior has test coverage
- [ ] This is the simplest viable approach
- [ ] AI provenance section removed or accurate
Write HTML as typed Python classes. Your editor autocompletes attributes, your type checker validates nesting:
152
+
Write HTML as typed Python classes. Using Python allows your editor to autocomplete attributes, and your type checker to validate nesting:
153
153
154
154
`main.py`:
155
155
@@ -161,17 +161,21 @@ app = air.Air()
161
161
162
162
@app.page
163
163
defindex():
164
-
return air.Html(air.H1("Hello, world!"))
164
+
return air.Html(
165
+
air.H1("Hello, world!"),
166
+
)
165
167
```
166
168
167
-
### Run either one
169
+
## Running Air's Development Server
170
+
171
+
Either approach produces the same thing: a working web page.
172
+
173
+
To see the result, run the following command and open <http://127.0.0.1:8000> in your browser.
168
174
169
175
```sh
170
176
air run
171
177
```
172
178
173
-
Open <http://127.0.0.1:8000> to see the result. Both paths produce the same thing: a working web page.
174
-
175
179
## Use FastAPI Alongside Air
176
180
177
181
Air is powered by FastAPI. You get Air's HTML tools for your pages and FastAPI's full capabilities for your API, all in one app.
Copy file name to clipboardExpand all lines: docs/api/routing.md
+15-13Lines changed: 15 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,24 +1,23 @@
1
-
Routing
1
+
## Routing
2
2
3
-
If you need to knit several Python modules with their own Air views into one, that's where Routing is used. They allow the near seamless combination of multiple Air apps into one. Larger sites are often built from multiple routers.
3
+
If you need to knit several Python modules with their own Air views into one, you will need to use Routing. This allow the near seamless combination of multiple Air apps into one. Larger sites are often built from multiple routers.
4
4
5
-
Let's imagine we have an e-commerce store with a shopping cart app. Use instantiate a `router` object using `air.AirRouter()` just as we would with `air.App()`:
5
+
For this example, let's imagine we have an e-commerce store with a shopping cart app with a `cart.py` and `main.py` file.
6
6
7
-
```python
8
-
# cart.py
7
+
```python title="cart.py"
9
8
import air
10
9
11
10
router = air.AirRouter()
12
11
13
12
14
13
@router.page
15
-
defcart():
14
+
defcart_page():
16
15
return air.H1("I am a shopping cart")
17
16
```
18
17
19
-
Then in our main page we can load that and tie it into our main`app`.
18
+
Then in our main page we can load that and tie it into our `main.py`app.
20
19
21
-
```python
20
+
```python title="main.py"
22
21
import air
23
22
from cart import router as cart_router
24
23
@@ -31,21 +30,24 @@ def index():
31
30
return air.H1("Home page")
32
31
```
33
32
34
-
Note that the router allows sharing of sessions and other application states.
33
+
`AirRouter` allows the sharing of sessions and other application states between routes.
35
34
36
-
In addition, we can add links through the `.url()` method available on route functions, which generates URLs programmatically:
35
+
In addition, we can add links through the `.url()` method available on route functions:
This example uses [Air Tags](api/tags/index.md), which are Python classes that render as HTML. Air Tags are typed and documented, designed to work well with any code completion tool.
148
152
153
+
### Running Air
154
+
155
+
To run the development server, run the following command in your terminal:
156
+
157
+
```sh
158
+
air run
159
+
```
160
+
161
+
Open <http://127.0.0.1:8000> to see the above example running.
162
+
149
163
## Combining FastAPI and Air
150
164
151
165
Air is just a layer over FastAPI. So it is trivial to combine sophisticated HTML pages and a REST API into one app.
`AirForm[ContactMessage]` gives you type-safe validated data. `ContactMessage.create()` writes it to PostgreSQL. Your editor knows the types at every step.
0 commit comments