Repository navigation
Expand file tree
/
Copy pathllms.txt
More file actions
63 lines (49 loc) · 4.95 KB
/
Copy pathllms.txt
File metadata and controls
63 lines (49 loc) · 4.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Tina4 Python
> Tina4 Python (`tina4-python` on PyPI) is a web framework for Python 3.12+ with zero runtime dependencies: routing, ORM, Frond (Twig-compatible) templates, JWT auth, sessions, queues, WebSocket, GraphQL, WSDL/SOAP and Swagger are all built in, and database drivers are optional extras. It is one of four Tina4 backends (Python, PHP, Ruby, Node.js) that share the same project layout, CLI, template syntax and `.env` variables.
Quick start. Install the Rust `tina4` CLI (`curl -fsSL https://tina4.com/install.sh | sh`, `brew install tina4stack/tap/tina4`, or `irm https://tina4.com/install.ps1 | iex` on Windows), then:
```bash
tina4 init python my-app # the path is required; creates .venv and installs tina4-python
cd my-app
tina4 serve # http://localhost:7146 (TINA4_PORT overrides)
```
Add a route by dropping a file in `src/routes/` (auto-discovered):
```python
from tina4_python.core.router import get
@get("/api/hello/{name}")
async def hello(name, request, response):
return response({"message": f"Hello, {name}!"})
```
Gotchas an agent most needs:
- GET routes are public; POST, PUT, PATCH and DELETE require a bearer token by default. Use `@noauth()` to open a write route and `@secured()` to protect a GET. Decorator order, outermost first: `@noauth`/`@secured`, then `@description`/`@tags`, then the route decorator.
- Path parameters arrive as handler arguments whose names match the `{placeholders}` (Python only; the other Tina4 backends read `request.params`).
- `response(data, status)` returns JSON for a dict; `response.json(...)` and `response.render("page.twig", data)` also exist.
- In an `async def` handler, call the `_async` twin of every database and ORM call (`await db.fetch_one_async(...)`, `await user.save_async()`); a plain `def` handler runs in a worker thread and may use the sync calls.
- ORM columns are field objects from `tina4_python.orm` (`IntegerField`, `StringField`, ...). The table name defaults to the lowercase class name; set `table_name` or `TINA4_ORM_PLURAL_TABLE_NAMES=true`.
- The database comes from `TINA4_DATABASE_URL` (`sqlite:///`, `postgresql://`, `mysql://`, `mssql://`, `firebird://`). Change schema only through SQL files in `migrations/`, never in route code.
- The package's own CLI is `tina4python` (not `tina4py`); the `tina4` CLI forwards `tina4 generate <model|route|crud|migration|...>` to it. Generated write routes are secure by default.
## Docs
- [Quick reference](https://tina4.com/python/index.md): one-page cheat sheet of every feature
- [Getting started](https://tina4.com/python/01-getting-started.md): install, scaffold, project layout, first route
- [Routing](https://tina4.com/python/02-routing.md): methods, path parameters, route groups, auth decorators, wildcards
- [Request and response](https://tina4.com/python/03-request-response.md): request fields, response helpers, status codes, validation, uploads
- [Templates](https://tina4.com/python/04-templates.md): Frond template engine, filters, inheritance
- [Database](https://tina4.com/python/05-database.md): configuration, parameterised queries, transactions, migrations, seeding
- [ORM](https://tina4.com/python/06-orm.md): models, CRUD, relationships, eager loading, soft delete, auto-CRUD
- [Authentication](https://tina4.com/python/08-authentication.md): JWT tokens, password hashing, login flow, protecting routes, CSRF
- [Middleware and security](https://tina4.com/python/10-middleware-security.md): the middleware pipeline, built-in and custom middleware
- [Queues](https://tina4.com/python/12-queues.md): producers, consumers, retries, dead letters, backends
- [Scaffolding](https://tina4.com/python/19-scaffolding.md): `tina4 generate` generators
- [CLI](https://tina4.com/python/31-cli.md): every `tina4` and `tina4python` command
- [Environment variables](https://tina4.com/python/33-environment-variables.md): the `.env` reference
- [Deployment](https://tina4.com/python/34-deployment.md): production config, Docker, health checks, reverse proxy, scaling
- [Release notes](https://tina4.com/python/36-releases.md): what changed in each release
- [Upgrading from v2](https://tina4.com/python/37-upgrading-from-v2.md): migration guide from Tina4 Python v2
## Repository
- [CLAUDE.md](https://raw.githubusercontent.com/tina4stack/tina4-python/v3/CLAUDE.md): maintainer guide to this codebase
- [Packaged CLAUDE.md](https://raw.githubusercontent.com/tina4stack/tina4-python/v3/tina4_python/CLAUDE.md): app-developer guide shipped inside the package
- [AGENTS.md](https://raw.githubusercontent.com/tina4stack/tina4-python/v3/AGENTS.md): instructions for coding agents
- [CHANGELOG.md](https://raw.githubusercontent.com/tina4stack/tina4-python/v3/CHANGELOG.md): release history
## Optional
- [Tina4 site map](https://tina4.com/llms.txt): llms.txt for all of tina4.com, every language
- [Tina4 full docs](https://tina4.com/llms-full.txt): the whole documentation in one file
- [Feature list](https://tina4.com/python/38-feature-list.md): the full cataloged feature inventory