spiderweb-framework 2.3.0__tar.gz → 2.5.1__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.
Files changed (137) hide show
  1. spiderweb_framework-2.5.1/.github/workflows/publish.yml +23 -0
  2. spiderweb_framework-2.5.1/.github/workflows/retype.yml +26 -0
  3. spiderweb_framework-2.5.1/.github/workflows/tests.yml +30 -0
  4. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/PKG-INFO +2 -1
  5. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/docs/_sidebar.md +1 -0
  6. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/docs/asgi.md +1 -1
  7. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/docs/file_uploads.md +1 -1
  8. spiderweb_framework-2.5.1/docs/management.md +311 -0
  9. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/docs/middleware/custom_middleware.md +1 -1
  10. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/docs/middleware/gzip.md +1 -1
  11. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/docs/routes.md +140 -2
  12. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/docs/static_files.md +2 -2
  13. spiderweb_framework-2.5.1/example_auth.py +82 -0
  14. spiderweb_framework-2.5.1/example_profile.py +110 -0
  15. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/pyproject.toml +8 -1
  16. spiderweb_framework-2.5.1/retype.yml +19 -0
  17. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/__init__.py +1 -0
  18. spiderweb_framework-2.5.1/spiderweb/authentication.py +40 -0
  19. spiderweb_framework-2.5.1/spiderweb/cli.py +640 -0
  20. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/main.py +34 -4
  21. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/middleware/pydantic.py +2 -5
  22. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/middleware/sessions.py +14 -0
  23. spiderweb_framework-2.5.1/spiderweb/models/__init__.py +4 -0
  24. spiderweb_framework-2.5.1/spiderweb/models/permission.py +12 -0
  25. spiderweb_framework-2.5.1/spiderweb/models/user.py +134 -0
  26. spiderweb_framework-2.5.1/spiderweb/routegroup.py +44 -0
  27. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/routes.py +72 -14
  28. spiderweb_framework-2.5.1/spiderweb/tests/test_authentication.py +116 -0
  29. spiderweb_framework-2.5.1/spiderweb/tests/test_cli.py +672 -0
  30. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/tests/test_pydantic_middleware.py +36 -44
  31. spiderweb_framework-2.5.1/spiderweb/tests/test_routegroups.py +395 -0
  32. spiderweb_framework-2.5.1/spiderweb/tests/test_session_persistence.py +108 -0
  33. spiderweb_framework-2.5.1/spiderweb/tests/test_user.py +83 -0
  34. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/uv.lock +3 -1
  35. spiderweb_framework-2.3.0/.idea/dataSources/data_sources_history.xml +0 -40
  36. spiderweb_framework-2.3.0/.idea/db-forest-config.xml +0 -10
  37. spiderweb_framework-2.3.0/.idea/workspace.xml +0 -548
  38. spiderweb_framework-2.3.0/.junie/memory/errors.md +0 -0
  39. spiderweb_framework-2.3.0/.junie/memory/feedback.md +0 -0
  40. spiderweb_framework-2.3.0/.junie/memory/language.json +0 -1
  41. spiderweb_framework-2.3.0/.junie/memory/memory.version +0 -1
  42. spiderweb_framework-2.3.0/.junie/memory/tasks.md +0 -0
  43. spiderweb_framework-2.3.0/CLAUDE.md +0 -156
  44. spiderweb_framework-2.3.0/architecture/asgi.md +0 -745
  45. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/.gitignore +0 -0
  46. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/.idea/.gitignore +0 -0
  47. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/.idea/inspectionProfiles/Project_Default.xml +0 -0
  48. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/.idea/inspectionProfiles/profiles_settings.xml +0 -0
  49. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/.idea/misc.xml +0 -0
  50. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/.idea/modules.xml +0 -0
  51. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/.idea/spiderweb.iml +0 -0
  52. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/.idea/vcs.xml +0 -0
  53. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/.junie/guidelines.md +0 -0
  54. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/LICENSE.txt +0 -0
  55. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/Makefile +0 -0
  56. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/README.md +0 -0
  57. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/conftest.py +0 -0
  58. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/docs/.nojekyll +0 -0
  59. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/docs/README.md +0 -0
  60. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/docs/_coverpage.md +0 -0
  61. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/docs/_media/DMSans-Bold.ttf +0 -0
  62. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/docs/_media/DMSans-Medium.ttf +0 -0
  63. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/docs/_media/Favicon-32x32.png +0 -0
  64. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/docs/_media/favicon.png +0 -0
  65. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/docs/_media/spiderweb_logo.png +0 -0
  66. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/docs/_media/spiderweb_logo_cleaned.png +0 -0
  67. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/docs/_media/spiderweb_logo_cropped.png +0 -0
  68. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/docs/db.md +0 -0
  69. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/docs/example.md +0 -0
  70. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/docs/index.html +0 -0
  71. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/docs/middleware/cors.md +0 -0
  72. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/docs/middleware/csrf.md +0 -0
  73. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/docs/middleware/overview.md +0 -0
  74. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/docs/middleware/pydantic.md +0 -0
  75. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/docs/middleware/sessions.md +0 -0
  76. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/docs/quickstart.md +0 -0
  77. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/docs/responses.md +0 -0
  78. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/example.py +0 -0
  79. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/example2.py +0 -0
  80. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/example_async.py +0 -0
  81. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/example_async_middleware.py +0 -0
  82. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/example_middleware.py +0 -0
  83. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/asgi.py +0 -0
  84. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/constants.py +0 -0
  85. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/converters.py +0 -0
  86. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/db.py +0 -0
  87. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/decorators.py +0 -0
  88. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/default_views.py +0 -0
  89. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/example_validator.py +0 -0
  90. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/exceptions.py +0 -0
  91. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/files.py +0 -0
  92. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/jinja_core.py +0 -0
  93. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/jinja_extensions.py +0 -0
  94. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/local_server.py +0 -0
  95. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/middleware/__init__.py +0 -0
  96. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/middleware/base.py +0 -0
  97. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/middleware/cors.py +0 -0
  98. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/middleware/csrf.py +0 -0
  99. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/middleware/gzip.py +0 -0
  100. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/request.py +0 -0
  101. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/response.py +0 -0
  102. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/secrets.py +0 -0
  103. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/server_checks.py +0 -0
  104. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/tests/__init__.py +0 -0
  105. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/tests/helpers.py +0 -0
  106. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/tests/middleware.py +0 -0
  107. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/tests/staticfiles/.gitkeep +0 -0
  108. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/tests/staticfiles/file_for_testing_fileresponse.txt +0 -0
  109. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/tests/staticfiles/style.css +0 -0
  110. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/tests/test.html +0 -0
  111. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/tests/test_asgi.py +0 -0
  112. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/tests/test_asgi_extra.py +0 -0
  113. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/tests/test_cookies.py +0 -0
  114. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/tests/test_coverage_extras.py +0 -0
  115. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/tests/test_db.py +0 -0
  116. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/tests/test_exceptions.py +0 -0
  117. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/tests/test_files.py +0 -0
  118. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/tests/test_jinja_extras.py +0 -0
  119. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/tests/test_local_server.py +0 -0
  120. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/tests/test_local_server_extra.py +0 -0
  121. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/tests/test_main_extra.py +0 -0
  122. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/tests/test_middleware.py +0 -0
  123. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/tests/test_middleware_init.py +0 -0
  124. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/tests/test_responses.py +0 -0
  125. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/tests/test_secrets.py +0 -0
  126. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/tests/test_server.py +0 -0
  127. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/tests/test_server_checks.py +0 -0
  128. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/tests/test_utils.py +0 -0
  129. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/tests/test_variable_urls.py +0 -0
  130. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/tests/views_for_tests.py +0 -0
  131. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/spiderweb/utils.py +0 -0
  132. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/static_files/aaaaaa.gif +0 -0
  133. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/templates/base.html +0 -0
  134. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/templates/file_upload.html +0 -0
  135. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/templates/form.html +0 -0
  136. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/templates/test.html +0 -0
  137. {spiderweb_framework-2.3.0 → spiderweb_framework-2.5.1}/tools/update_version.py +0 -0
@@ -0,0 +1,23 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ publish:
9
+ name: Build and publish to PyPI
10
+ runs-on: ubuntu-latest
11
+
12
+ steps:
13
+ - uses: actions/checkout@v6
14
+
15
+ - uses: astral-sh/setup-uv@v8.0.0
16
+
17
+ - name: Build package
18
+ run: uv build
19
+
20
+ - name: Publish to PyPI
21
+ run: uv publish
22
+ env:
23
+ UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }}
@@ -0,0 +1,26 @@
1
+ name: Publish Retype powered website to GitHub Pages
2
+ on:
3
+ workflow_dispatch:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ jobs:
9
+ publish:
10
+ name: Publish to retype branch
11
+
12
+ runs-on: ubuntu-latest
13
+
14
+ permissions:
15
+ contents: write
16
+
17
+ steps:
18
+ - uses: actions/checkout@v6
19
+
20
+ - uses: retypeapp/action-build@latest
21
+ with:
22
+ key: ${{ secrets.RETYPE_PASSWORD }}
23
+
24
+ - uses: retypeapp/action-github-pages@latest
25
+ with:
26
+ update-branch: true
@@ -0,0 +1,30 @@
1
+ name: Tests
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+
7
+ jobs:
8
+ test:
9
+ runs-on: ubuntu-latest
10
+ strategy:
11
+ matrix:
12
+ python-version: ["3.11", "3.12", "3.13", "3.14"]
13
+
14
+ steps:
15
+ - uses: actions/checkout@v6
16
+
17
+ - name: Install uv
18
+ uses: astral-sh/setup-uv@v8.0.0
19
+ with:
20
+ version: "latest"
21
+ enable-cache: true
22
+
23
+ - name: Set up Python ${{ matrix.python-version }}
24
+ run: uv python install ${{ matrix.python-version }}
25
+
26
+ - name: Install project
27
+ run: uv sync --python ${{ matrix.python-version }}
28
+
29
+ - name: Run tests
30
+ run: uv run python -m pytest
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: spiderweb-framework
3
- Version: 2.3.0
3
+ Version: 2.5.1
4
4
  Summary: A small web framework, just big enough for a spider.
5
5
  Project-URL: Homepage, https://github.com/itsthejoker/spiderweb
6
6
  Project-URL: Documentation, https://github.com/itsthejoker/spiderweb
@@ -22,6 +22,7 @@ Classifier: Topic :: Internet :: WWW/HTTP :: WSGI :: Application
22
22
  Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
23
23
  Requires-Python: >=3.11
24
24
  Requires-Dist: advanced-alchemy<2.0.0,>=1.6.3
25
+ Requires-Dist: alembic>=1.17.0
25
26
  Requires-Dist: cryptography>=46.0.2
26
27
  Requires-Dist: email-validator>=2.3.0
27
28
  Requires-Dist: jinja2>=3.1.6
@@ -14,3 +14,4 @@
14
14
  - [writing your own](middleware/custom_middleware.md)
15
15
  - [databases](db.md)
16
16
  - [asgi](asgi.md)
17
+ - [management](management.md)
@@ -1,6 +1,6 @@
1
1
  # asgi
2
2
 
3
- > New in 2.3.0!
3
+ [!badge New in 2.3.0!]
4
4
 
5
5
  Spiderweb supports both WSGI and ASGI from the same `SpiderwebRouter` instance. Your existing WSGI app continues to work exactly as before; ASGI is strictly opt-in.
6
6
 
@@ -1,6 +1,6 @@
1
1
  # handling file uploads
2
2
 
3
- > New in 2.2.0!
3
+ [!badge New in 2.2.0!]
4
4
 
5
5
  Spiderweb supports handling file uploads via standard HTML forms that use multipart/form-data. Uploaded files are parsed into Request.FILES as a MultiDict of MediaFile objects, which provide convenient helpers like filename, content_type, size, read(), seek(), and save().
6
6
 
@@ -0,0 +1,311 @@
1
+ # management
2
+
3
+ [!badge New in 2.4.0!]
4
+
5
+ Spiderweb ships with a built-in management CLI — a single command you can use to start the dev server, explore your routes, open an interactive shell, and run startup checks. If you've ever used Django's `manage.py`, this will feel familiar.
6
+
7
+ After installing the package, the `web` command is available in your environment:
8
+
9
+ ```shell
10
+ web --help
11
+ ```
12
+
13
+ ## pointing the CLI at your app
14
+
15
+ All commands (except `version`) need to know which `SpiderwebRouter` instance to work with. There are three ways to tell them, in order of priority:
16
+
17
+ **1. The `--app` flag**
18
+
19
+ Pass the app location directly on the command line as `module:attribute`:
20
+
21
+ ```shell
22
+ web --app myapp:app serve
23
+ ```
24
+
25
+ **2. The `SPIDERWEB_APP` environment variable**
26
+
27
+ This is helpful for CI pipelines of for folks who like to have everything set in the shell.
28
+
29
+ ```shell
30
+ export SPIDERWEB_APP=myapp:app
31
+ web serve
32
+ ```
33
+
34
+ **3. `pyproject.toml`**
35
+
36
+ Add a `[tool.spiderweb]` section to your project's `pyproject.toml`. The CLI walks up from your current directory until it finds one:
37
+
38
+ ```toml
39
+ [tool.spiderweb]
40
+ app = "myapp:app"
41
+ ```
42
+
43
+ With that in place you can use any command bare, with no flags at all:
44
+
45
+ ```shell
46
+ web serve
47
+ ```
48
+
49
+ > [!TIP]
50
+ > The `pyproject.toml` approach is the most ergonomic for day-to-day development. Set it once and forget about it.
51
+
52
+ ## commands
53
+
54
+ ### version
55
+
56
+ Prints the installed version of `spiderweb`. This is the one command that doesn't need an app.
57
+
58
+ ```shell
59
+ $ web version
60
+ spiderweb-framework 2.4.0
61
+ ```
62
+
63
+ ### serve
64
+
65
+ Starts the development server. By default it runs in WSGI mode on whatever address and port your app was configured with (`localhost:8000` unless you changed them).
66
+
67
+ ```shell
68
+ web serve
69
+ ```
70
+
71
+ Switch to ASGI mode with `--asgi`:
72
+
73
+ ```shell
74
+ web serve --asgi
75
+ ```
76
+
77
+ Override the bind address or port without touching your source code:
78
+
79
+ ```shell
80
+ web serve --addr 0.0.0.0 --port 9000
81
+ ```
82
+
83
+ If your project always runs in ASGI mode, set `asgi = true` in `[tool.spiderweb]`:
84
+
85
+ ```toml
86
+ [tool.spiderweb]
87
+ app = "myapp:app"
88
+ asgi = true
89
+ ```
90
+
91
+ You can still override it on the command line in either direction — `--asgi` forces ASGI, `--wsgi` forces WSGI regardless of what `pyproject.toml` says.
92
+
93
+ > [!WARNING]
94
+ > The dev server is just that: for development. Do not use for production.
95
+
96
+ ### shell
97
+
98
+ Opens an interactive Python interpreter with your app already loaded as `app`. Great for poking around at runtime state, testing a database query, or trying out a piece of logic before committing it.
99
+
100
+ ```shell
101
+ $ spiderweb shell
102
+ Spiderweb 2.4.0 shell
103
+ Available names: app
104
+ Type "exit()" or Ctrl-D to quit.
105
+
106
+ >>> app.addr
107
+ 'localhost'
108
+ >>> with app.get_db_session() as session:
109
+ ... # query away
110
+ ... pass
111
+ ```
112
+
113
+ If [IPython](https://ipython.org/) is installed in your environment, the shell will use it automatically. Otherwise, it falls back to the standard library `code.interact`.
114
+
115
+ ### routes
116
+
117
+ Prints a table of every URL route your app has registered — path, allowed methods, optional name, and the view function.
118
+
119
+ ```shell
120
+ $ spiderweb routes
121
+ path methods name view
122
+ -----------------------------------------------------------------------
123
+ / POST, GET, PUT, PATCH, DELETE index
124
+ /about POST, GET, PUT, PATCH, DELETE about
125
+ /posts/{slug} POST, GET, PUT, PATCH, DELETE posts get_post
126
+ ```
127
+
128
+ Routes that haven't restricted their methods show the full default set. If you pass `allowed_methods=["GET"]` to `@app.route()`, only that method appears in the table. Handy for double-checking that a new route was picked up correctly, or for tracking down a duplicate.
129
+
130
+ ### check
131
+
132
+ Re-runs all middleware startup checks and tells you whether everything looks healthy.
133
+
134
+ ```shell
135
+ $ web check
136
+ System check passed.
137
+ ```
138
+
139
+ If any check fails, a `StartupErrors` exception group is raised — you'll see a one-frame traceback listing every failing check. Useful in CI or as a quick sanity check after a config change.
140
+
141
+ ### makemigrations
142
+
143
+ Generates a new Alembic migration by comparing your current models against the database schema.
144
+
145
+ ```shell
146
+ web makemigrations
147
+ web makemigrations -m "add users table"
148
+ ```
149
+
150
+ The first time you run this command the CLI scaffolds a `migrations/` directory next to your `pyproject.toml` (or in the current directory if no `pyproject.toml` is found):
151
+
152
+ ```
153
+ migrations/
154
+ env.py ← configure your model metadata here
155
+ script.py.mako ← template for generated migration files
156
+ versions/ ← individual migration scripts live here
157
+ ```
158
+
159
+ By default, Alembic compares spiderweb's own internal tables against the live database. To include your own models, open `migrations/env.py` and add your `Base` to `target_metadata`:
160
+
161
+ ```python
162
+ from myapp.models import Base as _AppBase
163
+
164
+ target_metadata = [_SpiderwebBase.metadata, _AppBase.metadata]
165
+ ```
166
+
167
+ **Options**
168
+
169
+ | Flag | Description |
170
+ |---|---|
171
+ | `-m MESSAGE` / `--message MESSAGE` | Short description embedded in the migration filename. |
172
+ | `--empty` | Create a blank migration without running autogenerate. Useful for hand-written data migrations. |
173
+
174
+ ### migrate
175
+
176
+ Applies pending migrations to the database. Without arguments it upgrades to the latest revision (`head`).
177
+
178
+ ```shell
179
+ web migrate
180
+ ```
181
+
182
+ Pass a specific revision ID, a relative step, or the special value `zero` to target a particular point in the migration history:
183
+
184
+ ```shell
185
+ web migrate abc123de # upgrade (or already at this rev: no-op)
186
+ web migrate +1 # apply the next pending migration
187
+ web migrate -1 # roll back the most recent migration
188
+ web migrate zero # roll back every migration (equivalent to `base`)
189
+ ```
190
+
191
+ **Options**
192
+
193
+ | Flag | Description |
194
+ |---|---|
195
+ | `REVISION` | Target revision (default: `head`). |
196
+ | `--fake` | Stamp the database at the target revision without executing any SQL — useful for marking existing schemas as migrated. |
197
+
198
+ > [!TIP]
199
+ > You can configure where the migrations directory lives by setting `migrations_dir` in `[tool.spiderweb]`:
200
+ >
201
+ > ```toml
202
+ > [tool.spiderweb]
203
+ > app = "myapp:app"
204
+ > migrations_dir = "db/migrations"
205
+ > ```
206
+
207
+ ## custom commands
208
+
209
+ You can register your own management commands on the router using the `@app.command()` decorator. Every custom command receives three arguments:
210
+
211
+ - `app` — the `SpiderwebRouter` instance, so you can access the database, routes, config, etc.
212
+ - `args` — an `argparse.Namespace` containing only `.app` and `.command` (the values the CLI's own pre-parser resolved). It does **not** contain any flags you pass after the command name.
213
+ - `extra` — a plain `list[str]` of every token that appeared after the command name on the command line. Parse this yourself if your command accepts flags.
214
+
215
+ A command with no extra flags:
216
+
217
+ ```python
218
+ from spiderweb import SpiderwebRouter
219
+ from spiderweb.response import HttpResponse
220
+
221
+ app = SpiderwebRouter()
222
+
223
+ @app.route("/")
224
+ def index(request):
225
+ return HttpResponse("hello!")
226
+
227
+ @app.command("seed")
228
+ def seed_database(app, args, extra):
229
+ """Populate the database with initial data."""
230
+ with app.get_db_session() as session:
231
+ # ... insert seed records ...
232
+ session.commit()
233
+ print("Database seeded.")
234
+
235
+ if __name__ == "__main__":
236
+ app.start()
237
+ ```
238
+
239
+ A command that accepts its own flags — parse `extra` with argparse:
240
+
241
+ ```python
242
+ import argparse
243
+
244
+ @app.command("seed")
245
+ def seed_database(app, args, extra):
246
+ p = argparse.ArgumentParser(prog="spiderweb seed")
247
+ p.add_argument("--dry-run", action="store_true")
248
+ opts = p.parse_args(extra)
249
+
250
+ if opts.dry_run:
251
+ print("Dry run — no changes written.")
252
+ return
253
+
254
+ with app.get_db_session() as session:
255
+ session.commit()
256
+ print("Database seeded.")
257
+ ```
258
+
259
+ ```shell
260
+ web seed --dry-run
261
+ ```
262
+
263
+ Run any custom command the same way as a built-in:
264
+
265
+ ```shell
266
+ web --app myapp:app seed
267
+ ```
268
+
269
+ Or, with `pyproject.toml` configured, just:
270
+
271
+ ```shell
272
+ web seed
273
+ ```
274
+
275
+ > [!NOTE]
276
+ > The decorated function is still a regular Python function. Applying `@app.command()` doesn't change it in any way — you can still call it directly in your own code.
277
+
278
+ You can register as many custom commands as you like. Pick meaningful names; they'll show up in the error message if someone types an unrecognised command, so short and descriptive is best.
279
+
280
+ ## configuration reference
281
+
282
+ | Option | Description |
283
+ |---|---|
284
+ | `--app MODULE:ATTR` | The app to use, in `module:attribute` form. Overrides `SPIDERWEB_APP` and `pyproject.toml`. |
285
+ | `SPIDERWEB_APP` | Environment variable. Overrides `pyproject.toml`, overridden by `--app`. |
286
+ | `[tool.spiderweb] app` | `pyproject.toml` key. Lowest priority; used when neither of the above is set. |
287
+ | `[tool.spiderweb] asgi` | `pyproject.toml` boolean. When `true`, `serve` defaults to ASGI mode. Overridden by `--asgi` / `--wsgi`. |
288
+ | `[tool.spiderweb] migrations_dir` | Path to the Alembic migrations directory, relative to `pyproject.toml`. Defaults to `migrations`. |
289
+
290
+ ### `serve` options
291
+
292
+ | Flag | Description |
293
+ |---|---|
294
+ | `--asgi` | Start in ASGI mode via uvicorn instead of WSGI. |
295
+ | `--wsgi` | Force WSGI mode even when `asgi = true` is set in `pyproject.toml`. |
296
+ | `--addr ADDR` | Bind address. Overrides the value stored in the app. |
297
+ | `--port PORT` | Port number. Overrides the value stored in the app. |
298
+
299
+ ### `makemigrations` options
300
+
301
+ | Flag | Description |
302
+ |---|---|
303
+ | `-m MESSAGE` / `--message MESSAGE` | Short description for the migration. |
304
+ | `--empty` | Create a blank migration without autogenerate. |
305
+
306
+ ### `migrate` options
307
+
308
+ | Flag | Description |
309
+ |---|---|
310
+ | `REVISION` | Target revision (default: `head`). Accepts revision IDs, `+N`/`-N` relative specs, `zero`, or `base`. |
311
+ | `--fake` | Stamp the database at the target revision without running SQL. |
@@ -57,7 +57,7 @@ This is a helper function that is available for you to override; it's not often
57
57
 
58
58
  ## post_process(self, request: Request, response: HttpResponse, rendered_response: str) -> str | bytes:
59
59
 
60
- > New in 1.3.0!
60
+ [!badge New in 1.3.0!]
61
61
 
62
62
  After `process_request` and `process_response` run, the response is rendered out into the raw text that is going to be sent to the client. Right before that happens, `post_process` is called on each middleware in the same order as `process_response` (so the closer something is to the beginning of the middleware list, the more important it is).
63
63
 
@@ -1,6 +1,6 @@
1
1
  # gzip compression middleware
2
2
 
3
- > New in 1.4.0!
3
+ [!badge New in 1.4.0!]
4
4
 
5
5
  ```python
6
6
  from spiderweb import SpiderwebRouter
@@ -116,7 +116,7 @@ In this case, a valid URL might be `/example/3/james`, and both sections will be
116
116
 
117
117
  The `path` option is special; this is used when you want to capture everything after the slash. For example:
118
118
 
119
- > New in 1.2.0!
119
+ [!badge New in 1.2.0!]
120
120
 
121
121
  ```python
122
122
  @app.route("/example/<path:rest>")
@@ -165,7 +165,7 @@ As with the `routes` argument, as many routes as you'd like can be registered he
165
165
 
166
166
  ## Finding Routes Again
167
167
 
168
- > New in 1.1.0!
168
+ [!badge New in 1.1.0!]
169
169
 
170
170
  If you need to find the path that's associated with a route (for example, for a RedirectResponse), you can use the `app.reverse()` function to find it. This function takes the name of the view and returns the path that it's associated with. For example:
171
171
 
@@ -197,3 +197,141 @@ print(path) # -> "/example/3?name=james"
197
197
  ```
198
198
 
199
199
  The arguments you pass in must match what the path expects, or you'll get a `SpiderwebException`. If there's no route with that name, you'll get a `ReverseNotFound` exception instead.
200
+
201
+ ## Route Groups
202
+
203
+ [!badge New in 2.4.0!]
204
+
205
+ As your application grows, keeping all of its routes in one file becomes unwieldy. Route groups let you define a set of related routes together — with a shared URL prefix — and then mount them onto your app in one shot.
206
+
207
+ ```python
208
+ from spiderweb import SpiderwebRouter, RouteGroup
209
+ from spiderweb.response import HttpResponse, JsonResponse
210
+
211
+ api = RouteGroup(prefix="/api")
212
+
213
+ @api.route("/users")
214
+ def list_users(request):
215
+ return JsonResponse({"users": []})
216
+
217
+ @api.route("/users/<int:id>")
218
+ def get_user(request, id):
219
+ return JsonResponse({"id": id})
220
+
221
+ app = SpiderwebRouter()
222
+ app.include_routegroup(api)
223
+
224
+ if __name__ == "__main__":
225
+ app.start()
226
+ ```
227
+
228
+ The two routes above are registered as `/api/users` and `/api/users/<int:id>`. Everything else works exactly as it would if you had written `@app.route("/api/users")` yourself — URL parameter conversion, `allowed_methods`, all of it.
229
+
230
+ You can also use `add_route()` on a group directly, without the decorator:
231
+
232
+ ```python
233
+ api = RouteGroup(prefix="/api")
234
+ api.add_route("/status", status_view, allowed_methods=["GET"], name="status")
235
+ ```
236
+
237
+ ### Namespaces
238
+
239
+ If you give a route group a `namespace`, route names inside it are automatically prefixed with `"namespace:"`. This keeps reverse lookups unambiguous when two groups have routes with the same local name.
240
+
241
+ ```python
242
+ v1 = RouteGroup(prefix="/v1", namespace="v1")
243
+ v2 = RouteGroup(prefix="/v2", namespace="v2")
244
+
245
+ @v1.route("/ping", name="ping")
246
+ def ping_v1(request):
247
+ return HttpResponse("v1")
248
+
249
+ @v2.route("/ping", name="ping")
250
+ def ping_v2(request):
251
+ return HttpResponse("v2")
252
+
253
+ app = SpiderwebRouter()
254
+ app.include_routegroup(v1)
255
+ app.include_routegroup(v2)
256
+
257
+ app.reverse("v1:ping") # -> "/v1/ping"
258
+ app.reverse("v2:ping") # -> "/v2/ping"
259
+ ```
260
+
261
+ Without a namespace, route names pass through unchanged, so existing apps that don't need namespacing work exactly as before.
262
+
263
+ > [!TIP]
264
+ > You can include as many route groups as you like on the same app. Groups don't know about each other, so two groups that share the same prefix are fine as long as their individual paths don't clash.
265
+
266
+ ## Custom Path-Parameter Converters
267
+
268
+ [!badge New in 2.4.0!]
269
+
270
+ The built-in converters (`str`, `int`, `float`, `path`) cover the common cases, but sometimes you need a custom pattern — a UUID, a slug, a date string, and so on. You can teach Spiderweb new converters with `register_converter()`.
271
+
272
+ A converter is any class with two things:
273
+
274
+ - a `regex` class attribute — the pattern that must match the URL segment
275
+ - a `to_python()` method — converts the matched string to whatever Python type you want
276
+
277
+ ```python
278
+ from spiderweb import SpiderwebRouter
279
+ from spiderweb.response import HttpResponse
280
+
281
+ class SlugConverter:
282
+ regex = r"[-a-z0-9_]+"
283
+ name = "slug"
284
+
285
+ def to_python(self, value):
286
+ return str(value)
287
+
288
+ app = SpiderwebRouter()
289
+ app.register_converter(SlugConverter)
290
+
291
+ @app.route("/posts/<slug:post_slug>")
292
+ def get_post(request, post_slug):
293
+ return HttpResponse(f"post: {post_slug}")
294
+ ```
295
+
296
+ The `name` attribute controls what you write in the route path — `<slug:...>` in this case. If you leave `name` off the class, Spiderweb derives it automatically by lower-casing the class name and stripping a trailing `"converter"` (so `SlugConverter` becomes `"slug"` either way).
297
+
298
+ ### A more complete example
299
+
300
+ Here's a UUID converter that hands you a proper `uuid.UUID` object in your view:
301
+
302
+ ```python
303
+ import uuid
304
+
305
+ class UUIDConverter:
306
+ regex = r"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"
307
+ name = "uuid"
308
+
309
+ def to_python(self, value):
310
+ return uuid.UUID(value)
311
+
312
+ app.register_converter(UUIDConverter)
313
+
314
+ @app.route("/records/<uuid:record_id>")
315
+ def get_record(request, record_id):
316
+ # record_id is a uuid.UUID instance here
317
+ return HttpResponse(str(record_id))
318
+ ```
319
+
320
+ Custom converters work inside route groups too — just register them on the app before calling `include_routegroup()`:
321
+
322
+ ```python
323
+ app.register_converter(SlugConverter)
324
+
325
+ blog = RouteGroup(prefix="/blog", namespace="blog")
326
+
327
+ @blog.route("/<slug:post_slug>", name="post")
328
+ def blog_post(request, post_slug):
329
+ return HttpResponse(post_slug)
330
+
331
+ app.include_routegroup(blog)
332
+
333
+ app.reverse("blog:post", {"post_slug": "hello-world"}) # -> "/blog/hello-world"
334
+ ```
335
+
336
+ > [!NOTE]
337
+ > Custom converters don't replace the built-ins. You can mix `<int:id>` and `<uuid:uid>` in the same app without any conflict.
@@ -39,7 +39,7 @@ This is the URL that Spiderweb will use to serve static files. In the example ab
39
39
 
40
40
  ## `debug`
41
41
 
42
- > New in 1.2.0!
42
+ [!badge New in 1.2.0!]
43
43
 
44
44
  > default: `False`
45
45
 
@@ -47,7 +47,7 @@ This is a boolean that tells Spiderweb whether it is running in debug mode or no
47
47
 
48
48
  ## Linking to static files
49
49
 
50
- > New in 1.2.0!
50
+ [!badge New in 1.2.0!]
51
51
 
52
52
  There is a tag in the templates that you can use to link to static files. This tag will automatically generate the correct URL for the file based on the `static_url` attribute you set in the router.
53
53