spiderweb-framework 2.6.1__tar.gz → 2.8.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.
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/.github/workflows/retype.yml +4 -1
- spiderweb_framework-2.8.0/.github/workflows/update_badges.yml +160 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/PKG-INFO +28 -11
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/README.md +26 -9
- spiderweb_framework-2.8.0/badges/build.svg +1 -0
- spiderweb_framework-2.8.0/badges/coverage.svg +1 -0
- spiderweb_framework-2.8.0/badges/forks.svg +1 -0
- spiderweb_framework-2.8.0/badges/pypi-downloads-monthly.svg +1 -0
- spiderweb_framework-2.8.0/badges/pypi-version.svg +1 -0
- spiderweb_framework-2.8.0/badges/repo-size.svg +1 -0
- spiderweb_framework-2.8.0/badges/stars.svg +1 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/docs/_sidebar.md +3 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/docs/asgi.md +4 -6
- spiderweb_framework-2.8.0/docs/authentication.md +136 -0
- spiderweb_framework-2.8.0/docs/logging.md +56 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/docs/management.md +11 -13
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/docs/middleware/csrf.md +1 -1
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/docs/middleware/custom_middleware.md +1 -1
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/docs/middleware/pydantic.md +1 -1
- spiderweb_framework-2.8.0/docs/middleware/security_headers.md +76 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/docs/quickstart.md +13 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/docs/routes.md +18 -8
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/pyproject.toml +2 -1
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/asgi.py +30 -7
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/authentication.py +6 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/constants.py +1 -0
- spiderweb_framework-2.8.0/spiderweb/debug.py +36 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/exceptions.py +7 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/jinja_extensions.py +13 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/main.py +68 -9
- spiderweb_framework-2.8.0/spiderweb/middleware/security_headers.py +62 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/request.py +8 -9
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/routes.py +15 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/tests/test_asgi.py +1 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/tests/test_authentication.py +16 -0
- spiderweb_framework-2.8.0/spiderweb/tests/test_debug.py +165 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/tests/test_jinja_extras.py +24 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/tests/test_main_extra.py +13 -0
- spiderweb_framework-2.8.0/spiderweb/tests/test_request.py +167 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/tests/test_responses.py +9 -12
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/tests/test_routes.py +30 -0
- spiderweb_framework-2.8.0/spiderweb/tests/test_security_headers.py +104 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/tests/test_session_persistence.py +58 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/utils.py +16 -0
- spiderweb_framework-2.8.0/uv.lock +1333 -0
- spiderweb_framework-2.6.1/.junie/guidelines.md +0 -140
- spiderweb_framework-2.6.1/uv.lock +0 -1115
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/.github/workflows/publish.yml +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/.github/workflows/tests.yml +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/.gitignore +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/.idea/.gitignore +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/.idea/inspectionProfiles/Project_Default.xml +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/.idea/inspectionProfiles/profiles_settings.xml +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/.idea/misc.xml +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/.idea/modules.xml +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/.idea/spiderweb.iml +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/.idea/vcs.xml +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/LICENSE.txt +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/Makefile +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/conftest.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/docs/.nojekyll +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/docs/README.md +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/docs/_coverpage.md +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/docs/_media/DMSans-Bold.ttf +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/docs/_media/DMSans-Medium.ttf +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/docs/_media/Favicon-32x32.png +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/docs/_media/favicon.png +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/docs/_media/spiderweb_logo.png +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/docs/_media/spiderweb_logo_cleaned.png +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/docs/_media/spiderweb_logo_cropped.png +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/docs/db.md +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/docs/file_uploads.md +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/docs/index.html +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/docs/middleware/cors.md +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/docs/middleware/gzip.md +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/docs/middleware/index.md +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/docs/middleware/index.yml +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/docs/middleware/sessions.md +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/docs/responses.md +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/docs/static_files.md +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/example.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/example2.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/example_async.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/example_async_middleware.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/example_auth.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/example_class_based_view.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/example_middleware.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/example_profile.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/retype.yml +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/__init__.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/cli.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/converters.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/db.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/decorators.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/default_views.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/example_validator.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/files.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/jinja_core.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/local_server.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/middleware/__init__.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/middleware/base.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/middleware/cors.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/middleware/csrf.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/middleware/gzip.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/middleware/pydantic.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/middleware/sessions.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/models/__init__.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/models/permission.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/models/user.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/response.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/routegroup.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/secrets.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/server_checks.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/tests/__init__.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/tests/helpers.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/tests/middleware.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/tests/staticfiles/.gitkeep +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/tests/staticfiles/file_for_testing_fileresponse.txt +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/tests/staticfiles/style.css +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/tests/test.html +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/tests/test_asgi_extra.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/tests/test_cli.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/tests/test_cookies.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/tests/test_coverage_extras.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/tests/test_db.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/tests/test_exceptions.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/tests/test_files.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/tests/test_local_server.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/tests/test_local_server_extra.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/tests/test_middleware.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/tests/test_middleware_init.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/tests/test_pydantic_middleware.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/tests/test_routegroups.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/tests/test_secrets.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/tests/test_server.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/tests/test_server_checks.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/tests/test_user.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/tests/test_utils.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/tests/test_variable_urls.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/spiderweb/tests/views_for_tests.py +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/static_files/aaaaaa.gif +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/templates/base.html +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/templates/file_upload.html +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/templates/form.html +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/templates/test.html +0 -0
- {spiderweb_framework-2.6.1 → spiderweb_framework-2.8.0}/tools/update_version.py +0 -0
|
@@ -17,10 +17,13 @@ jobs:
|
|
|
17
17
|
steps:
|
|
18
18
|
- uses: actions/checkout@v6
|
|
19
19
|
|
|
20
|
+
- name: Generate llms.txt
|
|
21
|
+
uses: zakaria-chahboun/retype_llms@v3.0.1
|
|
22
|
+
|
|
20
23
|
- uses: retypeapp/action-build@latest
|
|
21
24
|
with:
|
|
22
25
|
key: ${{ secrets.RETYPE_PASSWORD }}
|
|
23
26
|
|
|
24
27
|
- uses: retypeapp/action-github-pages@latest
|
|
25
28
|
with:
|
|
26
|
-
update-branch: true
|
|
29
|
+
update-branch: true
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# Ripped wholesale from the nanocoder folks.
|
|
2
|
+
|
|
3
|
+
name: Update Status Badges
|
|
4
|
+
on:
|
|
5
|
+
workflow_dispatch:
|
|
6
|
+
schedule:
|
|
7
|
+
- cron: '0 0 * * *' # Once a day at midnight UTC
|
|
8
|
+
release:
|
|
9
|
+
types: [published]
|
|
10
|
+
|
|
11
|
+
permissions:
|
|
12
|
+
contents: write
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
generate-badges:
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
steps:
|
|
18
|
+
- name: Checkout
|
|
19
|
+
uses: actions/checkout@v6
|
|
20
|
+
|
|
21
|
+
- name: Setup uv
|
|
22
|
+
uses: astral-sh/setup-uv@v8.0.0
|
|
23
|
+
with:
|
|
24
|
+
version: "latest"
|
|
25
|
+
enable-cache: true
|
|
26
|
+
|
|
27
|
+
- name: Setup Python
|
|
28
|
+
uses: actions/setup-python@v6.2.0
|
|
29
|
+
with:
|
|
30
|
+
python-version-file: "pyproject.toml"
|
|
31
|
+
|
|
32
|
+
- name: Install dependencies
|
|
33
|
+
run: uv sync
|
|
34
|
+
|
|
35
|
+
- name: Run tests for latest coverage
|
|
36
|
+
run: uv run coverage run -m pytest && uv run coverage json || echo "Coverage test failed or not available"
|
|
37
|
+
|
|
38
|
+
- name: Extract coverage (if available)
|
|
39
|
+
id: coverage
|
|
40
|
+
run: |
|
|
41
|
+
if [ -f "coverage.json" ]; then
|
|
42
|
+
COVERAGE=$(cat coverage.json | jq -r '.totals.percent_covered_display // "N/A"')
|
|
43
|
+
echo "percentage=${COVERAGE}" >> $GITHUB_OUTPUT
|
|
44
|
+
else
|
|
45
|
+
echo "percentage=N/A" >> $GITHUB_OUTPUT
|
|
46
|
+
fi
|
|
47
|
+
|
|
48
|
+
- name: Run build to check status
|
|
49
|
+
id: build
|
|
50
|
+
run: |
|
|
51
|
+
if uv build; then
|
|
52
|
+
echo "status=passing" >> $GITHUB_OUTPUT
|
|
53
|
+
echo "color=brightgreen" >> $GITHUB_OUTPUT
|
|
54
|
+
else
|
|
55
|
+
echo "status=failing" >> $GITHUB_OUTPUT
|
|
56
|
+
echo "color=red" >> $GITHUB_OUTPUT
|
|
57
|
+
fi
|
|
58
|
+
|
|
59
|
+
- name: Generate badges
|
|
60
|
+
run: |
|
|
61
|
+
# Create badges directory if it doesn't exist
|
|
62
|
+
mkdir -p badges
|
|
63
|
+
|
|
64
|
+
# Coverage badge (with fallback if coverage not available) - with for-the-badge style
|
|
65
|
+
if [ "${{ steps.coverage.outputs.percentage }}" != "N/A" ]; then
|
|
66
|
+
COVERAGE_PERCENTAGE="${{ steps.coverage.outputs.percentage }}"
|
|
67
|
+
COVERAGE_COLOR=$(echo "${COVERAGE_PERCENTAGE}" | awk '{print ($1 >= 80) ? "brightgreen" : ($1 >= 50) ? "yellow" : "red"}')
|
|
68
|
+
curl -s "https://img.shields.io/badge/coverage-${COVERAGE_PERCENTAGE}%25-${COVERAGE_COLOR}?style=for-the-badge" > badges/coverage.svg
|
|
69
|
+
else
|
|
70
|
+
curl -s "https://img.shields.io/badge/coverage-N%2FA-lightgrey?style=for-the-badge" > badges/coverage.svg
|
|
71
|
+
fi
|
|
72
|
+
|
|
73
|
+
# Build status badge - with for-the-badge style and githubactions logo
|
|
74
|
+
curl -s "https://img.shields.io/badge/build-${{ steps.build.outputs.status }}-${{ steps.build.outputs.color }}?style=for-the-badge&logo=githubactions" > badges/build.svg
|
|
75
|
+
|
|
76
|
+
# PyPI Downloads (monthly) - with for-the-badge style and pypi logo
|
|
77
|
+
curl -s "https://img.shields.io/pypi/dm/spiderweb-framework?style=for-the-badge&logo=pypi" > badges/pypi-downloads-monthly.svg
|
|
78
|
+
|
|
79
|
+
# GitHub Repo Size - with for-the-badge style and github logo
|
|
80
|
+
curl -s "https://img.shields.io/github/repo-size/itsthejoker/spiderweb?style=for-the-badge&logo=github" > badges/repo-size.svg
|
|
81
|
+
|
|
82
|
+
# GitHub Repo Stars - with for-the-badge style and github logo
|
|
83
|
+
curl -s "https://img.shields.io/github/stars/itsthejoker/spiderweb?style=for-the-badge&logo=github" > badges/stars.svg
|
|
84
|
+
|
|
85
|
+
# GitHub Forks - with for-the-badge style and github logo
|
|
86
|
+
curl -s "https://img.shields.io/github/forks/itsthejoker/spiderweb?style=for-the-badge&logo=github" > badges/forks.svg
|
|
87
|
+
|
|
88
|
+
# PyPI version - with for-the-badge style and pypi logo
|
|
89
|
+
curl -s "https://img.shields.io/pypi/v/spiderweb-framework?style=for-the-badge&logo=pypi" > badges/pypi-version.svg
|
|
90
|
+
|
|
91
|
+
# - name: Update README with badges
|
|
92
|
+
# run: |
|
|
93
|
+
# # Update badges in README.md
|
|
94
|
+
# if [ -f "README.md" ]; then
|
|
95
|
+
# # Create a temporary file to avoid direct modification issues
|
|
96
|
+
# cp README.md README.md.tmp
|
|
97
|
+
#
|
|
98
|
+
# # If badges section doesn't exist, add it after the first heading
|
|
99
|
+
# if ! grep -q 'alt="Build status"\|alt="Coverage"' README.md.tmp; then
|
|
100
|
+
# # Add HTML badges after the first heading
|
|
101
|
+
# sed -i '2i \
|
|
102
|
+
# \
|
|
103
|
+
# <p align="center">\
|
|
104
|
+
# <img\
|
|
105
|
+
# src="https://github.com/itsthejoker/spiderweb/raw/main/badges/build.svg"\
|
|
106
|
+
# alt="Build status"\
|
|
107
|
+
# />\
|
|
108
|
+
# <img\
|
|
109
|
+
# src="https://github.com/itsthejoker/spiderweb/raw/main/badges/coverage.svg"\
|
|
110
|
+
# alt="Coverage"\
|
|
111
|
+
# />\
|
|
112
|
+
# <img\
|
|
113
|
+
# src="https://github.com/itsthejoker/spiderweb/raw/main/badges/pypi-version.svg"\
|
|
114
|
+
# alt="Version"\
|
|
115
|
+
# />\
|
|
116
|
+
# <img\
|
|
117
|
+
# src="https://github.com/itsthejoker/spiderweb/raw/main/badges/pypi-downloads-monthly.svg"\
|
|
118
|
+
# alt="Downloads"\
|
|
119
|
+
# />\
|
|
120
|
+
# <img\
|
|
121
|
+
# src="https://github.com/itsthejoker/spiderweb/raw/main/badges/stars.svg"\
|
|
122
|
+
# alt="Stars"\
|
|
123
|
+
# />\
|
|
124
|
+
# <img\
|
|
125
|
+
# src="https://github.com/itsthejoker/spiderweb/raw/main/badges/repo-size.svg"\
|
|
126
|
+
# alt="Repo Size"\
|
|
127
|
+
# />\
|
|
128
|
+
# <img\
|
|
129
|
+
# src="https://github.com/itsthejoker/spiderweb/raw/main/badges/forks.svg"\
|
|
130
|
+
# alt="Forks"\
|
|
131
|
+
# />\
|
|
132
|
+
# <img\
|
|
133
|
+
# src="https://img.shields.io/badge/gitmoji-%20😜%20😍-FFDD67.svg?style=for-the-badge"\
|
|
134
|
+
# alt="Gitmoji"\
|
|
135
|
+
# />\
|
|
136
|
+
# <img\
|
|
137
|
+
# src="https://img.shields.io/badge/code%20style-black-000000.svg?style=for-the-badge"\
|
|
138
|
+
# alt="Code style: Black"\
|
|
139
|
+
# />\
|
|
140
|
+
# </p>\
|
|
141
|
+
# \
|
|
142
|
+
# ' README.md.tmp
|
|
143
|
+
# fi
|
|
144
|
+
#
|
|
145
|
+
# # Replace the original file
|
|
146
|
+
# mv README.md.tmp README.md
|
|
147
|
+
# fi
|
|
148
|
+
|
|
149
|
+
- name: Commit and push badges
|
|
150
|
+
run: |
|
|
151
|
+
git config --local user.email "action@github.com"
|
|
152
|
+
git config --local user.name "GitHub Action"
|
|
153
|
+
git add badges/ README.md
|
|
154
|
+
# Only commit if there are staged changes
|
|
155
|
+
if ! git diff --cached --quiet; then
|
|
156
|
+
git commit -m "📈 update status badges" || echo "No changes to commit"
|
|
157
|
+
git push
|
|
158
|
+
else
|
|
159
|
+
echo "No changes to commit"
|
|
160
|
+
fi
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: spiderweb-framework
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.8.0
|
|
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
|
|
@@ -39,8 +39,32 @@ Description-Content-Type: text/markdown
|
|
|
39
39
|
|
|
40
40
|
<p align="center">
|
|
41
41
|
<img
|
|
42
|
-
src="https://
|
|
43
|
-
alt="
|
|
42
|
+
src="https://github.com/itsthejoker/spiderweb/raw/main/badges/build.svg"
|
|
43
|
+
alt="Build status"
|
|
44
|
+
/>
|
|
45
|
+
<img
|
|
46
|
+
src="https://github.com/itsthejoker/spiderweb/raw/main/badges/coverage.svg"
|
|
47
|
+
alt="Coverage"
|
|
48
|
+
/>
|
|
49
|
+
<img
|
|
50
|
+
src="https://github.com/itsthejoker/spiderweb/raw/main/badges/pypi-version.svg"
|
|
51
|
+
alt="Version"
|
|
52
|
+
/>
|
|
53
|
+
<img
|
|
54
|
+
src="https://github.com/itsthejoker/spiderweb/raw/main/badges/pypi-downloads-monthly.svg"
|
|
55
|
+
alt="Downloads"
|
|
56
|
+
/>
|
|
57
|
+
<img
|
|
58
|
+
src="https://github.com/itsthejoker/spiderweb/raw/main/badges/stars.svg"
|
|
59
|
+
alt="Stars"
|
|
60
|
+
/>
|
|
61
|
+
<img
|
|
62
|
+
src="https://github.com/itsthejoker/spiderweb/raw/main/badges/repo-size.svg"
|
|
63
|
+
alt="Repo Size"
|
|
64
|
+
/>
|
|
65
|
+
<img
|
|
66
|
+
src="https://github.com/itsthejoker/spiderweb/raw/main/badges/forks.svg"
|
|
67
|
+
alt="Forks"
|
|
44
68
|
/>
|
|
45
69
|
<img
|
|
46
70
|
src="https://img.shields.io/badge/gitmoji-%20😜%20😍-FFDD67.svg?style=for-the-badge"
|
|
@@ -52,13 +76,6 @@ Description-Content-Type: text/markdown
|
|
|
52
76
|
/>
|
|
53
77
|
</p>
|
|
54
78
|
|
|
55
|
-
<p align="center">
|
|
56
|
-
<img
|
|
57
|
-
src="https://github.com/itsthejoker/spiderweb/actions/workflows/tests.yml/badge.svg?branch=main"
|
|
58
|
-
alt="Code style: Black"
|
|
59
|
-
/>
|
|
60
|
-
</p>
|
|
61
|
-
|
|
62
79
|
As a professional web developer focusing on arcane uses of Django for arcane purposes, it occurred to me a little while ago that I didn't actually know how a web framework _worked_.
|
|
63
80
|
|
|
64
81
|
So I built one.
|
|
@@ -2,8 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
<p align="center">
|
|
4
4
|
<img
|
|
5
|
-
src="https://
|
|
6
|
-
alt="
|
|
5
|
+
src="https://github.com/itsthejoker/spiderweb/raw/main/badges/build.svg"
|
|
6
|
+
alt="Build status"
|
|
7
|
+
/>
|
|
8
|
+
<img
|
|
9
|
+
src="https://github.com/itsthejoker/spiderweb/raw/main/badges/coverage.svg"
|
|
10
|
+
alt="Coverage"
|
|
11
|
+
/>
|
|
12
|
+
<img
|
|
13
|
+
src="https://github.com/itsthejoker/spiderweb/raw/main/badges/pypi-version.svg"
|
|
14
|
+
alt="Version"
|
|
15
|
+
/>
|
|
16
|
+
<img
|
|
17
|
+
src="https://github.com/itsthejoker/spiderweb/raw/main/badges/pypi-downloads-monthly.svg"
|
|
18
|
+
alt="Downloads"
|
|
19
|
+
/>
|
|
20
|
+
<img
|
|
21
|
+
src="https://github.com/itsthejoker/spiderweb/raw/main/badges/stars.svg"
|
|
22
|
+
alt="Stars"
|
|
23
|
+
/>
|
|
24
|
+
<img
|
|
25
|
+
src="https://github.com/itsthejoker/spiderweb/raw/main/badges/repo-size.svg"
|
|
26
|
+
alt="Repo Size"
|
|
27
|
+
/>
|
|
28
|
+
<img
|
|
29
|
+
src="https://github.com/itsthejoker/spiderweb/raw/main/badges/forks.svg"
|
|
30
|
+
alt="Forks"
|
|
7
31
|
/>
|
|
8
32
|
<img
|
|
9
33
|
src="https://img.shields.io/badge/gitmoji-%20😜%20😍-FFDD67.svg?style=for-the-badge"
|
|
@@ -15,13 +39,6 @@
|
|
|
15
39
|
/>
|
|
16
40
|
</p>
|
|
17
41
|
|
|
18
|
-
<p align="center">
|
|
19
|
-
<img
|
|
20
|
-
src="https://github.com/itsthejoker/spiderweb/actions/workflows/tests.yml/badge.svg?branch=main"
|
|
21
|
-
alt="Code style: Black"
|
|
22
|
-
/>
|
|
23
|
-
</p>
|
|
24
|
-
|
|
25
42
|
As a professional web developer focusing on arcane uses of Django for arcane purposes, it occurred to me a little while ago that I didn't actually know how a web framework _worked_.
|
|
26
43
|
|
|
27
44
|
So I built one.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="162" height="28" role="img" aria-label="BUILD: PASSING"><title>BUILD: PASSING</title><g shape-rendering="crispEdges"><rect width="78.25" height="28" fill="#555"/><rect x="78.25" width="83.75" height="28" fill="#4b0"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="100"><image x="9" y="7" width="14" height="14" href="data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2MuMDE4LS4wMDIuMDM1LjAwNi4wNTIuMDA3QTMuNTAzIDMuNTAzIDAgMCAxIDIwLjUgMTdjMS45MyAwIDMuNSAxLjU3IDMuNSAzLjV6bS0xIDBjMC0xLjM3OC0xLjEyMi0yLjUtMi41LTIuNVMxOCAxOS4xMjIgMTggMjAuNXMxLjEyMiAyLjUgMi41IDIuNSAyLjUtMS4xMjIgMi41LTIuNXoiLz48L3N2Zz4="/><text transform="scale(.1)" x="476.25" y="175" textLength="372.5">BUILD</text><text transform="scale(.1)" x="1201.25" y="175" textLength="597.5" font-weight="bold">PASSING</text></g></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="142.75" height="28" role="img" aria-label="COVERAGE: 94%"><title>COVERAGE: 94%</title><g shape-rendering="crispEdges"><rect width="89" height="28" fill="#555"/><rect x="89" width="53.75" height="28" fill="#4b0"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="100"><text transform="scale(.1)" x="445" y="175" textLength="650">COVERAGE</text><text transform="scale(.1)" x="1158.75" y="175" textLength="297.5" font-weight="bold">94%</text></g></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="113.5" height="28"><g shape-rendering="crispEdges"><rect width="81.25" height="28" fill="#555"/><rect x="81.25" width="32.25" height="28" fill="#007ec6"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="100"><image x="9" y="7" width="14" height="14" href="data:image/svg+xml;base64,PHN2ZyBmaWxsPSJ3aGl0ZXNtb2tlIiByb2xlPSJpbWciIHZpZXdCb3g9IjAgMCAyNCAyNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48dGl0bGU+R2l0SHViPC90aXRsZT48cGF0aCBkPSJNMTIgLjI5N2MtNi42MyAwLTEyIDUuMzczLTEyIDEyIDAgNS4zMDMgMy40MzggOS44IDguMjA1IDExLjM4NS42LjExMy44Mi0uMjU4LjgyLS41NzcgMC0uMjg1LS4wMS0xLjA0LS4wMTUtMi4wNC0zLjMzOC43MjQtNC4wNDItMS42MS00LjA0Mi0xLjYxQzQuNDIyIDE4LjA3IDMuNjMzIDE3LjcgMy42MzMgMTcuN2MtMS4wODctLjc0NC4wODQtLjcyOS4wODQtLjcyOSAxLjIwNS4wODQgMS44MzggMS4yMzYgMS44MzggMS4yMzYgMS4wNyAxLjgzNSAyLjgwOSAxLjMwNSAzLjQ5NS45OTguMTA4LS43NzYuNDE3LTEuMzA1Ljc2LTEuNjA1LTIuNjY1LS4zLTUuNDY2LTEuMzMyLTUuNDY2LTUuOTMgMC0xLjMxLjQ2NS0yLjM4IDEuMjM1LTMuMjItLjEzNS0uMzAzLS41NC0xLjUyMy4xMDUtMy4xNzYgMCAwIDEuMDA1LS4zMjIgMy4zIDEuMjMuOTYtLjI2NyAxLjk4LS4zOTkgMy0uNDA1IDEuMDIuMDA2IDIuMDQuMTM4IDMgLjQwNSAyLjI4LTEuNTUyIDMuMjg1LTEuMjMgMy4yODUtMS4yMy42NDUgMS42NTMuMjQgMi44NzMuMTIgMy4xNzYuNzY1Ljg0IDEuMjMgMS45MSAxLjIzIDMuMjIgMCA0LjYxLTIuODA1IDUuNjI1LTUuNDc1IDUuOTIuNDIuMzYuODEgMS4wOTYuODEgMi4yMiAwIDEuNjA2LS4wMTUgMi44OTYtLjAxNSAzLjI4NiAwIC4zMTUuMjEuNjkuODI1LjU3QzIwLjU2NSAyMi4wOTIgMjQgMTcuNTkyIDI0IDEyLjI5N2MwLTYuNjI3LTUuMzczLTEyLTEyLTEyIi8+PC9zdmc+"/><a target="_blank" href="https://github.com/itsthejoker/spiderweb/fork"><rect width="81.25" height="28" fill="rgba(0,0,0,0)"/><text transform="scale(.1)" x="491.25" y="175" textLength="402.5">FORKS</text></a><a target="_blank" href="https://github.com/itsthejoker/spiderweb/network"><rect width="32.25" height="28" x="81.25" fill="rgba(0,0,0,0)"/><text transform="scale(.1)" x="973.75" y="175" textLength="82.5" font-weight="bold">2</text></a></g></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="215.25" height="28" role="img" aria-label="DOWNLOADS: 51/MONTH"><title>DOWNLOADS: 51/MONTH</title><g shape-rendering="crispEdges"><rect width="119.25" height="28" fill="#555"/><rect x="119.25" width="96" height="28" fill="#95991a"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="100"><image x="9" y="7" width="14" height="14" href="data:image/svg+xml;base64,PHN2ZyBmaWxsPSIjMzc3NUE5IiByb2xlPSJpbWciIHZpZXdCb3g9IjAgMCAyNCAyNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48dGl0bGU+UHlQSTwvdGl0bGU+PHBhdGggZD0iTTIzLjkyMiAxMy41OHYzLjkxMkwyMC41NSAxOC43MmwtLjA3OC4wNTUuMDUyLjAzNyAzLjQ1LTEuMjU2LjAyNi0uMDM2di0zLjk5N2wtLjA1My0uMDM2LS4wMjUuMDkyeiBNMjMuNjIxIDUuNjE4bC0zLjA0IDEuMTA3djMuOTEybDMuMzM5LTEuMjE1VjUuNTA5ek0yMy45MiAxMy40NTdWOS41NDRsLTMuMzM2IDEuMjE1djMuOTEzek0yMC40NyAxNC43MVYxMC44TDE3LjE3IDEydjMuOTEzek0xNy4wMzQgMTkuOTk2di0zLjkxMmwtMy4zMTMgMS4yMDZ2My45MTJ6TTE3LjE3IDE2LjA1N3YzLjg2OGwzLjMxNC0xLjIwNlYxNC44NWwtMy4zMTQgMS4yMDZ6bTIuMDkzIDEuODgyYy0uMzY3LjEzNC0uNjYzLS4wNzQtLjY2My0uNDYzcy4yOTYtLjgxNC42NjMtLjk0N2MuMzY1LS4xMzMuNjYyL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Ljk0OGwuMDM0LjAxMyAzLjI4NyAxLjE5Ni4wMTUtLjA3OC0zLjI2MS0xLjE4NyAzLjI2LTEuMTg3di0uMTA5TDMuODc2IDkuNjJsLS4zMDctLjExMiAzLjI2LTEuMTg4di44NzdsLjA3OS0uMDU1VjYuNzY5bDMuMjU3IDEuMTg1LjA1OC0uMDYxTDcuMDg0IDYuNzVsLS4xMDItLjAzNyAzLjI0LTEuMTc5di0uMDgzTDYuODU0IDYuNjc3di4wMThsLS4wMjUuMDE4djEuNTIzTDMuNDQgOS40N3YuMDJsLS4wMjUuMDE3djQuMDA3bC0zLjM5IDEuMjMzdi4wMTlMMCAxNC43ODR2My45OTVsLjAyNS4wMzcgMy40IDEuMjM3LjAwOC0uMDA2LjAwNy4wMSAzLjQgMS4yMzguMDA4LS4wMDYuMDA2LjAxIDMuNCAxLjIzNy4wMTQtLjAwOS4wMTIuMDEgMy40NS0xLjI1Ni4wMjYtLjAzNy0uMDc4LS4wMjd6TTMuNDkzIDkuNTYzbDMuMjU3IDEuMTg1LTMuMjU3IDEuMTg3VjkuNTYyek0zLjQgMTkuOTZMLjA3OCAxOC43NTJ2LTMuOTEzbDIuMzYxLjg2Ljk2LjM0OXYzLjkxM3ptLjAxNS0zLjk5TC4zMzUgMTQuODVsLS4xODItLjA2NiAzLjI2Mi0xLjE4N3YyLjM3NHptMy4zOTkgNS4yMzFsLTMuMzIxLTEuMjA5di0zLjkxMmwzLjMyMSAxLjIwOXYzLjkxMnpNMjMuNzkxIDUuNDM0bC0zLjIxLTEuMTd2Mi4zMzh6TTIwLjM4NyAyLjY0M2wtMy4yNC0xLjE4LTMuMjcgMS4xOSAzLjI0NyAxLjE4MnoiLz48L3N2Zz4="/><text transform="scale(.1)" x="681.25" y="175" textLength="782.5">DOWNLOADS</text><text transform="scale(.1)" x="1672.5" y="175" textLength="720" font-weight="bold">51/MONTH</text></g></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="135.5" height="28" role="img" aria-label="PYPI: V2.7.0"><title>PYPI: V2.7.0</title><g shape-rendering="crispEdges"><rect width="68" height="28" fill="#555"/><rect x="68" width="67.5" height="28" fill="#007ec6"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="100"><image x="9" y="7" width="14" height="14" href="data:image/svg+xml;base64,PHN2ZyBmaWxsPSIjMzc3NUE5IiByb2xlPSJpbWciIHZpZXdCb3g9IjAgMCAyNCAyNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48dGl0bGU+UHlQSTwvdGl0bGU+PHBhdGggZD0iTTIzLjkyMiAxMy41OHYzLjkxMkwyMC41NSAxOC43MmwtLjA3OC4wNTUuMDUyLjAzNyAzLjQ1LTEuMjU2LjAyNi0uMDM2di0zLjk5N2wtLjA1My0uMDM2LS4wMjUuMDkyeiBNMjMuNjIxIDUuNjE4bC0zLjA0IDEuMTA3djMuOTEybDMuMzM5LTEuMjE1VjUuNTA5ek0yMy45MiAxMy40NTdWOS41NDRsLTMuMzM2IDEuMjE1djMuOTEzek0yMC40NyAxNC43MVYxMC44TDE3LjE3IDEydjMuOTEzek0xNy4wMzQgMTkuOTk2di0zLjkxMmwtMy4zMTMgMS4yMDZ2My45MTJ6TTE3LjE3IDE2LjA1N3YzLjg2OGwzLjMxNC0xLjIwNlYxNC44NWwtMy4zMTQgMS4yMDZ6bTIuMDkzIDEuODgyYy0uMzY3LjEzNC0uNjYzLS4wNzQtLjY2My0uNDYzcy4yOTYtLjgxNC42NjMtLjk0N2MuMzY1LS4xMzMuNjYyLjA3NS42NjIuNDY0cy0uMjk3LjgxNC0uNjYyLjk0NnogTTEzLjIyNSA5LjMxNWwuMzY1LS4xMzItMy4yODUtMS4xOTctMy4zMjMgMS4yMS4xMDIuMDM3IDMuMTg0IDEuMTZ6TTIwLjUwNyAxMC42NjRWNi43NTFMMTcuMTcgNy45NjV2My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A1OC0uMDYxTDcuMDg0IDYuNzVsLS4xMDItLjAzNyAzLjI0LTEuMTc5di0uMDgzTDYuODU0IDYuNjc3di4wMThsLS4wMjUuMDE4djEuNTIzTDMuNDQgOS40N3YuMDJsLS4wMjUuMDE3djQuMDA3bC0zLjM5IDEuMjMzdi4wMTlMMCAxNC43ODR2My45OTVsLjAyNS4wMzcgMy40IDEuMjM3LjAwOC0uMDA2LjAwNy4wMSAzLjQgMS4yMzguMDA4LS4wMDYuMDA2LjAxIDMuNCAxLjIzNy4wMTQtLjAwOS4wMTIuMDEgMy40NS0xLjI1Ni4wMjYtLjAzNy0uMDc4LS4wMjd6TTMuNDkzIDkuNTYzbDMuMjU3IDEuMTg1LTMuMjU3IDEuMTg3VjkuNTYyek0zLjQgMTkuOTZMLjA3OCAxOC43NTJ2LTMuOTEzbDIuMzYxLjg2Ljk2LjM0OXYzLjkxM3ptLjAxNS0zLjk5TC4zMzUgMTQuODVsLS4xODItLjA2NiAzLjI2Mi0xLjE4N3YyLjM3NHptMy4zOTkgNS4yMzFsLTMuMzIxLTEuMjA5di0zLjkxMmwzLjMyMSAxLjIwOXYzLjkxMnpNMjMuNzkxIDUuNDM0bC0zLjIxLTEuMTd2Mi4zMzh6TTIwLjM4NyAyLjY0M2wtMy4yNC0xLjE4LTMuMjcgMS4xOSAzLjI0NyAxLjE4MnoiLz48L3N2Zz4="/><text transform="scale(.1)" x="425" y="175" textLength="270">PYPI</text><text transform="scale(.1)" x="1017.5" y="175" textLength="435" font-weight="bold">V2.7.0</text></g></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="182" height="28" role="img" aria-label="REPO SIZE: 1.4 MIB"><title>REPO SIZE: 1.4 MIB</title><g shape-rendering="crispEdges"><rect width="106.25" height="28" fill="#555"/><rect x="106.25" width="75.75" height="28" fill="#007ec6"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geomet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MjEuNjkuODI1LjU3QzIwLjU2NSAyMi4wOTIgMjQgMTcuNTkyIDI0IDEyLjI5N2MwLTYuNjI3LTUuMzczLTEyLTEyLTEyIi8+PC9zdmc+"/><text transform="scale(.1)" x="616.25" y="175" textLength="652.5">REPO SIZE</text><text transform="scale(.1)" x="1441.25" y="175" textLength="517.5" font-weight="bold">1.4 MIB</text></g></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="120.75" height="28"><g shape-rendering="crispEdges"><rect width="80.25" height="28" fill="#555"/><rect x="80.25" width="40.5" height="28" fill="#007ec6"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="100"><image x="9" y="7" width="14" height="14" href="data:image/svg+xml;base64,PHN2ZyBmaWxsPSJ3aGl0ZXNtb2tlIiByb2xlPSJpbWciIHZpZXdCb3g9IjAgMCAyNCAyNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48dGl0bGU+R2l0SHViPC90aXRsZT48cGF0aCBkPSJNMTIgLjI5N2MtNi42MyAwLTEyIDUuMzczLTEyIDEyIDAgNS4zMDMgMy40MzggOS44IDguMjA1IDExLjM4NS42LjExMy44Mi0uMjU4LjgyLS41NzcgMC0uMjg1LS4wMS0xLjA0LS4wMTUtMi4wNC0zLjMzOC43MjQtNC4wNDItMS42MS00LjA0Mi0xLjYxQzQuNDIyIDE4LjA3IDMuNjMzIDE3LjcgMy42MzMgMTcuN2MtMS4wODctLjc0NC4wODQtLjcyOS4wODQtLjcyOSAxLjIwNS4wODQgMS44MzggMS4yMzYgMS44MzggMS4yMzYgMS4wNyAxLjgzNSAyLjgwOSAxLjMwNSAzLjQ5NS45OTguMTA4LS43NzYuNDE3LTEuMzA1Ljc2LTEuNjA1LTIuNjY1LS4zLTUuNDY2LTEuMzMyLTUuNDY2LTUuOTMgMC0xLjMxLjQ2NS0yLjM4IDEuMjM1LTMuMjItLjEzNS0uMzAzLS41NC0xLjUyMy4xMDUtMy4xNzYgMCAwIDEuMDA1LS4zMjIgMy4zIDEuMjMuOTYtLjI2NyAxLjk4LS4zOTkgMy0uNDA1IDEuMDIuMDA2IDIuMDQuMTM4IDMgLjQwNSAyLjI4LTEuNTUyIDMuMjg1LTEuMjMgMy4yODUtMS4yMy42NDUgMS42NTMuMjQgMi44NzMuMTIgMy4xNzYuNzY1Ljg0IDEuMjMgMS45MSAxLjIzIDMuMjIgMCA0LjYxLTIuODA1IDUuNjI1LTUuNDc1IDUuOTIuNDIuMzYuODEgMS4wOTYuODEgMi4yMiAwIDEuNjA2LS4wMTUgMi44OTYtLjAxNSAzLjI4NiAwIC4zMTUuMjEuNjkuODI1LjU3QzIwLjU2NSAyMi4wOTIgMjQgMTcuNTkyIDI0IDEyLjI5N2MwLTYuNjI3LTUuMzczLTEyLTEyLTEyIi8+PC9zdmc+"/><a target="_blank" href="https://github.com/itsthejoker/spiderweb"><rect width="80.25" height="28" fill="rgba(0,0,0,0)"/><text transform="scale(.1)" x="486.25" y="175" textLength="392.5">STARS</text></a><a target="_blank" href="https://github.com/itsthejoker/spiderweb/stargazers"><rect width="40.5" height="28" x="80.25" fill="rgba(0,0,0,0)"/><text transform="scale(.1)" x="1005" y="175" textLength="165" font-weight="bold">57</text></a></g></svg>
|
|
@@ -11,7 +11,10 @@
|
|
|
11
11
|
- [cors](middleware/cors.md)
|
|
12
12
|
- [pydantic](middleware/pydantic.md)
|
|
13
13
|
- [gzip](middleware/gzip.md)
|
|
14
|
+
- [security headers](middleware/security_headers.md)
|
|
14
15
|
- [writing your own](middleware/custom_middleware.md)
|
|
15
16
|
- [databases](db.md)
|
|
17
|
+
- [authentication](authentication.md)
|
|
16
18
|
- [asgi](asgi.md)
|
|
17
19
|
- [management](management.md)
|
|
20
|
+
- [logging](logging.md)
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
---
|
|
2
2
|
icon: arrow-switch
|
|
3
|
-
nav:
|
|
4
|
-
badge: NEW|info
|
|
5
3
|
order: 0
|
|
6
4
|
---
|
|
7
5
|
|
|
@@ -74,7 +72,7 @@ hypercorn myapp:app.asgi_app
|
|
|
74
72
|
|
|
75
73
|
## Async Views
|
|
76
74
|
|
|
77
|
-
Views can be defined as `async def` and they will be awaited natively in ASGI mode. Sync views continue to work too
|
|
75
|
+
Views can be defined as `async def` and they will be awaited natively in ASGI mode. Sync views continue to work too -- they're dispatched via `asyncio.to_thread` so they don't block the event loop.
|
|
78
76
|
|
|
79
77
|
```python
|
|
80
78
|
@app.route("/sync")
|
|
@@ -90,7 +88,7 @@ Both of the above work under both WSGI and ASGI. There's no need to pick one or
|
|
|
90
88
|
|
|
91
89
|
## Lifespan Callbacks
|
|
92
90
|
|
|
93
|
-
You can register startup and shutdown callbacks when creating the router. These are called by the ASGI server during the lifespan protocol
|
|
91
|
+
You can register startup and shutdown callbacks when creating the router. These are called by the ASGI server during the lifespan protocol -- startup before the first request, shutdown after the last.
|
|
94
92
|
|
|
95
93
|
```python
|
|
96
94
|
def on_start():
|
|
@@ -162,10 +160,10 @@ You can use both protocols at the same time from the same `SpiderwebRouter` inst
|
|
|
162
160
|
```python
|
|
163
161
|
app = SpiderwebRouter()
|
|
164
162
|
|
|
165
|
-
# WSGI
|
|
163
|
+
# WSGI -- pass to gunicorn, wsgiref, etc.
|
|
166
164
|
wsgi_app = app
|
|
167
165
|
|
|
168
|
-
# ASGI
|
|
166
|
+
# ASGI -- pass to uvicorn, hypercorn, etc.
|
|
169
167
|
asgi_app = app.asgi_app
|
|
170
168
|
```
|
|
171
169
|
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
---
|
|
2
|
+
icon: person
|
|
3
|
+
nav:
|
|
4
|
+
badge: NEW|info
|
|
5
|
+
order: 700
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# authentication
|
|
9
|
+
|
|
10
|
+
[!badge New in 2.8.0!]
|
|
11
|
+
|
|
12
|
+
Spiderweb ships with a small built-in authentication system: a `User` model, a `Permission` model, and three helper functions -- `authenticate()`, `login()`, and `logout()`. It's deliberately minimal, but it covers the common case of "let visitors log in and stay logged in."
|
|
13
|
+
|
|
14
|
+
Authentication relies on sessions, so make sure the sessions middleware is enabled:
|
|
15
|
+
|
|
16
|
+
```python
|
|
17
|
+
from spiderweb import SpiderwebRouter
|
|
18
|
+
|
|
19
|
+
app = SpiderwebRouter(
|
|
20
|
+
middleware=["spiderweb.middleware.sessions.SessionMiddleware"],
|
|
21
|
+
)
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
> Read more [about the sessions middleware here](middleware/sessions.md).
|
|
25
|
+
|
|
26
|
+
## The User model
|
|
27
|
+
|
|
28
|
+
The `User` model lives in `spiderweb.models` and is stored in your app's database (the same one configured via the `db` argument):
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
from spiderweb.models import User
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
It has the fields you'd expect: `username` (unique), `email`, `first_name`, `last_name`, `password`, `is_active`, `is_staff`, `is_superuser`, `last_login`, and `date_joined`. Passwords are never stored in plain text -- `set_password()` hashes them with PBKDF2-SHA256, and `check_password()` verifies them:
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
db = app.get_db_session()
|
|
38
|
+
user = User(username="testuser", email="test@example.com")
|
|
39
|
+
user.set_password("password")
|
|
40
|
+
db.add(user)
|
|
41
|
+
db.commit()
|
|
42
|
+
db.close()
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
A few useful helpers on the model:
|
|
46
|
+
|
|
47
|
+
- `user.check_password("password")` -- returns `True`/`False`
|
|
48
|
+
- `user.has_usable_password()` -- `False` if the password was set to unusable
|
|
49
|
+
- `user.is_authenticated` / `user.is_anonymous` -- always `True`/`False` for a real user
|
|
50
|
+
- `user.get_full_name()` / `user.get_short_name()` / `user.get_username()`
|
|
51
|
+
|
|
52
|
+
## Logging users in and out
|
|
53
|
+
|
|
54
|
+
The `spiderweb.authentication` module gives you three functions:
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
from spiderweb.authentication import authenticate, login, logout
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
- `authenticate(request, username=..., password=...)` -- looks up the user and checks the password. Returns the `User` on success, `None` on failure.
|
|
61
|
+
- `login(request, user)` -- stores the user's id in the session, so they stay logged in on subsequent requests.
|
|
62
|
+
- `logout(request)` -- clears the session and resets `request.user` to an anonymous user.
|
|
63
|
+
|
|
64
|
+
Here's a typical login/logout pair of views:
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
from spiderweb.authentication import authenticate, login, logout
|
|
68
|
+
from spiderweb.response import RedirectResponse
|
|
69
|
+
|
|
70
|
+
@app.route("/login", allowed_methods=["POST"])
|
|
71
|
+
def do_login(request):
|
|
72
|
+
user = authenticate(
|
|
73
|
+
request,
|
|
74
|
+
username=request.POST.get("username"),
|
|
75
|
+
password=request.POST.get("password"),
|
|
76
|
+
)
|
|
77
|
+
if user:
|
|
78
|
+
login(request, user)
|
|
79
|
+
return RedirectResponse("/")
|
|
80
|
+
|
|
81
|
+
@app.route("/logout", allowed_methods=["POST"])
|
|
82
|
+
def do_logout(request):
|
|
83
|
+
logout(request)
|
|
84
|
+
return RedirectResponse("/")
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
> If your login form posts with CSRF protection enabled, either include the CSRF token in the form or mark the view `csrf_exempt`. See [the CSRF middleware](middleware/csrf.md).
|
|
88
|
+
|
|
89
|
+
## request.user
|
|
90
|
+
|
|
91
|
+
Once the sessions middleware is active, every request gets a `user` attribute. If the visitor is logged in, it's their `User` object; otherwise it's an `AnonymousUser` with `is_authenticated == False`. Checking whether someone is logged in is therefore just:
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
@app.route("/")
|
|
95
|
+
def index(request):
|
|
96
|
+
if request.user.is_authenticated:
|
|
97
|
+
return HttpResponse(f"Hello, {request.user.username}!")
|
|
98
|
+
return HttpResponse("Hello, stranger!")
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
`AnonymousUser` mirrors the same interface (`username`, `is_staff`, `is_superuser`, etc.), so you usually don't need to branch on the type -- just check `is_authenticated`.
|
|
102
|
+
|
|
103
|
+
## Permissions
|
|
104
|
+
|
|
105
|
+
[!badge New in 2.6.0!]
|
|
106
|
+
|
|
107
|
+
Users have a many-to-many relationship with the `Permission` model, available as `user.permissions`:
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
from spiderweb.models import Permission
|
|
111
|
+
|
|
112
|
+
db = app.get_db_session()
|
|
113
|
+
perm = Permission(name="Can publish posts", codename="publish_post")
|
|
114
|
+
db.add(perm)
|
|
115
|
+
db.commit()
|
|
116
|
+
|
|
117
|
+
user.permissions.append(perm)
|
|
118
|
+
db.commit()
|
|
119
|
+
db.close()
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Each `Permission` has a human-readable `name` and a unique `codename` you can check against in your views:
|
|
123
|
+
|
|
124
|
+
```python
|
|
125
|
+
@app.route("/publish", allowed_methods=["POST"])
|
|
126
|
+
def publish(request):
|
|
127
|
+
if not request.user.is_authenticated:
|
|
128
|
+
return RedirectResponse("/login")
|
|
129
|
+
if not any(p.codename == "publish_post" for p in request.user.permissions):
|
|
130
|
+
return HttpResponse("Forbidden", status_code=403)
|
|
131
|
+
...
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Full example
|
|
135
|
+
|
|
136
|
+
There's a complete, runnable version of all of this in the repo at `example_auth.py` -- spin it up with `python example_auth.py` and log in with `testuser` / `password`.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
---
|
|
2
|
+
icon: terminal
|
|
3
|
+
order: 860
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# logging
|
|
7
|
+
|
|
8
|
+
Spiderweb uses the standard library's `logging` module. Every `SpiderwebRouter` has a `log` attribute you can use for your own messages, and the framework logs its own events (startup checks, server start/stop, unhandled exceptions) through it.
|
|
9
|
+
|
|
10
|
+
```python
|
|
11
|
+
from spiderweb import SpiderwebRouter
|
|
12
|
+
|
|
13
|
+
app = SpiderwebRouter()
|
|
14
|
+
app.log.info("custom message from my app")
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## frameworks, logging, and you
|
|
18
|
+
|
|
19
|
+
As a library, Spiderweb does **not** call `logging.basicConfig()` -- it never modifies the root logger or installs handlers on it. The framework logger (`spiderweb.main`) carries its own stream handler at `INFO` level, so you still see messages like `Run startup checks...` out of the box, but your application's logging configuration is entirely yours to own.
|
|
20
|
+
|
|
21
|
+
If you configure logging in your own app, Spiderweb's messages will also propagate to your root handlers as usual:
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
import logging
|
|
25
|
+
|
|
26
|
+
logging.basicConfig(level=logging.DEBUG, format="%(levelname)s %(name)s: %(message)s")
|
|
27
|
+
|
|
28
|
+
from spiderweb import SpiderwebRouter
|
|
29
|
+
|
|
30
|
+
app = SpiderwebRouter()
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## using your own logger
|
|
34
|
+
|
|
35
|
+
Pass any `logging.Logger` to the router with the `log` parameter. This replaces the default framework logger for all of the app's messages:
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
import logging
|
|
39
|
+
|
|
40
|
+
from spiderweb import SpiderwebRouter
|
|
41
|
+
|
|
42
|
+
my_logger = logging.getLogger("myapp")
|
|
43
|
+
my_logger.setLevel(logging.DEBUG)
|
|
44
|
+
handler = logging.FileHandler("myapp.log")
|
|
45
|
+
my_logger.addHandler(handler)
|
|
46
|
+
|
|
47
|
+
app = SpiderwebRouter(log=my_logger)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## what gets logged
|
|
51
|
+
|
|
52
|
+
| Level | Examples |
|
|
53
|
+
|-------|----------|
|
|
54
|
+
| `INFO` | startup checks, server start/stop on the dev server |
|
|
55
|
+
| `WARNING` | static/media dirs set while `debug=False` |
|
|
56
|
+
| `ERROR` | unhandled view exceptions (with traceback), aborted connections |
|