spiderweb-framework 1.4.0__tar.gz → 2.0.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 (83) hide show
  1. spiderweb_framework-2.0.1/.gitignore +162 -0
  2. spiderweb_framework-2.0.1/.junie/guidelines.md +128 -0
  3. {spiderweb_framework-1.4.0 → spiderweb_framework-2.0.1}/LICENSE.txt +48 -48
  4. {spiderweb_framework-1.4.0 → spiderweb_framework-2.0.1}/PKG-INFO +28 -17
  5. {spiderweb_framework-1.4.0 → spiderweb_framework-2.0.1}/README.md +85 -72
  6. spiderweb_framework-2.0.1/conftest.py +12 -0
  7. spiderweb_framework-2.0.1/docs/README.md +133 -0
  8. spiderweb_framework-2.0.1/docs/_coverpage.md +9 -0
  9. spiderweb_framework-2.0.1/docs/_media/DMSans-Bold.ttf +1 -0
  10. spiderweb_framework-2.0.1/docs/_media/DMSans-Medium.ttf +0 -0
  11. spiderweb_framework-2.0.1/docs/_media/Favicon-32x32.png +0 -0
  12. spiderweb_framework-2.0.1/docs/_media/favicon.png +0 -0
  13. spiderweb_framework-2.0.1/docs/_media/spiderweb_logo.png +0 -0
  14. spiderweb_framework-2.0.1/docs/_media/spiderweb_logo_cleaned.png +0 -0
  15. spiderweb_framework-2.0.1/docs/_media/spiderweb_logo_cropped.png +0 -0
  16. spiderweb_framework-2.0.1/docs/_sidebar.md +14 -0
  17. spiderweb_framework-2.0.1/docs/db.md +100 -0
  18. spiderweb_framework-2.0.1/docs/example.md +19 -0
  19. spiderweb_framework-2.0.1/docs/index.html +73 -0
  20. spiderweb_framework-2.0.1/docs/middleware/cors.md +177 -0
  21. spiderweb_framework-2.0.1/docs/middleware/csrf.md +101 -0
  22. spiderweb_framework-2.0.1/docs/middleware/custom_middleware.md +172 -0
  23. spiderweb_framework-2.0.1/docs/middleware/gzip.md +51 -0
  24. spiderweb_framework-2.0.1/docs/middleware/overview.md +28 -0
  25. spiderweb_framework-2.0.1/docs/middleware/pydantic.md +60 -0
  26. spiderweb_framework-2.0.1/docs/middleware/sessions.md +85 -0
  27. spiderweb_framework-2.0.1/docs/quickstart.md +98 -0
  28. spiderweb_framework-2.0.1/docs/responses.md +151 -0
  29. spiderweb_framework-2.0.1/docs/routes.md +199 -0
  30. spiderweb_framework-2.0.1/docs/static_files.md +69 -0
  31. spiderweb_framework-2.0.1/example.py +120 -0
  32. spiderweb_framework-2.0.1/example2.py +79 -0
  33. spiderweb_framework-2.0.1/example_middleware.py +61 -0
  34. spiderweb_framework-2.0.1/poetry.lock +839 -0
  35. {spiderweb_framework-1.4.0 → spiderweb_framework-2.0.1}/pyproject.toml +96 -88
  36. {spiderweb_framework-1.4.0 → spiderweb_framework-2.0.1}/spiderweb/__init__.py +3 -3
  37. {spiderweb_framework-1.4.0 → spiderweb_framework-2.0.1}/spiderweb/constants.py +23 -27
  38. {spiderweb_framework-1.4.0 → spiderweb_framework-2.0.1}/spiderweb/converters.py +30 -30
  39. spiderweb_framework-2.0.1/spiderweb/db.py +28 -0
  40. {spiderweb_framework-1.4.0 → spiderweb_framework-2.0.1}/spiderweb/decorators.py +4 -4
  41. {spiderweb_framework-1.4.0 → spiderweb_framework-2.0.1}/spiderweb/default_views.py +33 -33
  42. {spiderweb_framework-1.4.0 → spiderweb_framework-2.0.1}/spiderweb/example_validator.py +8 -8
  43. {spiderweb_framework-1.4.0 → spiderweb_framework-2.0.1}/spiderweb/exceptions.py +96 -96
  44. {spiderweb_framework-1.4.0 → spiderweb_framework-2.0.1}/spiderweb/jinja_core.py +16 -16
  45. {spiderweb_framework-1.4.0 → spiderweb_framework-2.0.1}/spiderweb/jinja_extensions.py +19 -19
  46. {spiderweb_framework-1.4.0 → spiderweb_framework-2.0.1}/spiderweb/local_server.py +56 -56
  47. {spiderweb_framework-1.4.0 → spiderweb_framework-2.0.1}/spiderweb/main.py +372 -359
  48. {spiderweb_framework-1.4.0 → spiderweb_framework-2.0.1}/spiderweb/middleware/__init__.py +77 -77
  49. {spiderweb_framework-1.4.0 → spiderweb_framework-2.0.1}/spiderweb/middleware/base.py +59 -59
  50. {spiderweb_framework-1.4.0 → spiderweb_framework-2.0.1}/spiderweb/middleware/cors.py +161 -161
  51. {spiderweb_framework-1.4.0 → spiderweb_framework-2.0.1}/spiderweb/middleware/csrf.py +140 -138
  52. {spiderweb_framework-1.4.0 → spiderweb_framework-2.0.1}/spiderweb/middleware/gzip.py +70 -70
  53. {spiderweb_framework-1.4.0 → spiderweb_framework-2.0.1}/spiderweb/middleware/pydantic.py +74 -42
  54. spiderweb_framework-2.0.1/spiderweb/middleware/sessions.py +131 -0
  55. {spiderweb_framework-1.4.0 → spiderweb_framework-2.0.1}/spiderweb/request.py +106 -96
  56. {spiderweb_framework-1.4.0 → spiderweb_framework-2.0.1}/spiderweb/response.py +171 -171
  57. {spiderweb_framework-1.4.0 → spiderweb_framework-2.0.1}/spiderweb/routes.py +196 -196
  58. {spiderweb_framework-1.4.0 → spiderweb_framework-2.0.1}/spiderweb/secrets.py +26 -26
  59. {spiderweb_framework-1.4.0 → spiderweb_framework-2.0.1}/spiderweb/server_checks.py +18 -18
  60. {spiderweb_framework-1.4.0 → spiderweb_framework-2.0.1}/spiderweb/tests/helpers.py +28 -30
  61. {spiderweb_framework-1.4.0 → spiderweb_framework-2.0.1}/spiderweb/tests/middleware.py +40 -40
  62. spiderweb_framework-2.0.1/spiderweb/tests/staticfiles/.gitkeep +0 -0
  63. {spiderweb_framework-1.4.0 → spiderweb_framework-2.0.1}/spiderweb/tests/staticfiles/style.css +5 -5
  64. {spiderweb_framework-1.4.0 → spiderweb_framework-2.0.1}/spiderweb/tests/test_cookies.py +217 -149
  65. {spiderweb_framework-1.4.0 → spiderweb_framework-2.0.1}/spiderweb/tests/test_jinja_extras.py +35 -35
  66. {spiderweb_framework-1.4.0 → spiderweb_framework-2.0.1}/spiderweb/tests/test_middleware.py +924 -907
  67. {spiderweb_framework-1.4.0 → spiderweb_framework-2.0.1}/spiderweb/tests/test_responses.py +335 -335
  68. {spiderweb_framework-1.4.0 → spiderweb_framework-2.0.1}/spiderweb/tests/test_server.py +15 -15
  69. {spiderweb_framework-1.4.0 → spiderweb_framework-2.0.1}/spiderweb/tests/test_variable_urls.py +103 -103
  70. {spiderweb_framework-1.4.0 → spiderweb_framework-2.0.1}/spiderweb/tests/views_for_tests.py +52 -52
  71. {spiderweb_framework-1.4.0 → spiderweb_framework-2.0.1}/spiderweb/utils.py +108 -108
  72. spiderweb_framework-2.0.1/spiderweb.db +0 -0
  73. spiderweb_framework-2.0.1/static_files/aaaaaa.gif +0 -0
  74. spiderweb_framework-2.0.1/templates/base.html +18 -0
  75. spiderweb_framework-2.0.1/templates/form.html +21 -0
  76. spiderweb_framework-2.0.1/templates/test.html +21 -0
  77. spiderweb_framework-2.0.1/uv.lock +251 -0
  78. spiderweb_framework-1.4.0/spiderweb/db.py +0 -101
  79. spiderweb_framework-1.4.0/spiderweb/middleware/sessions.py +0 -104
  80. /spiderweb_framework-1.4.0/spiderweb/tests/__init__.py → /spiderweb_framework-2.0.1/docs/.nojekyll +0 -0
  81. /spiderweb_framework-1.4.0/spiderweb/tests/staticfiles/.gitkeep → /spiderweb_framework-2.0.1/spiderweb/tests/__init__.py +0 -0
  82. {spiderweb_framework-1.4.0 → spiderweb_framework-2.0.1}/spiderweb/tests/staticfiles/file_for_testing_fileresponse.txt +0 -0
  83. {spiderweb_framework-1.4.0 → spiderweb_framework-2.0.1}/spiderweb/tests/test.html +0 -0
@@ -0,0 +1,162 @@
1
+ # ---> Python
2
+ # Byte-compiled / optimized / DLL files
3
+ __pycache__/
4
+ *.py[cod]
5
+ *$py.class
6
+
7
+ # C extensions
8
+ *.so
9
+
10
+ # Distribution / packaging
11
+ .Python
12
+ build/
13
+ develop-eggs/
14
+ dist/
15
+ downloads/
16
+ eggs/
17
+ .eggs/
18
+ lib/
19
+ lib64/
20
+ parts/
21
+ sdist/
22
+ var/
23
+ wheels/
24
+ share/python-wheels/
25
+ *.egg-info/
26
+ .installed.cfg
27
+ *.egg
28
+ MANIFEST
29
+
30
+ # PyInstaller
31
+ # Usually these files are written by a python script from a template
32
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
33
+ *.manifest
34
+ *.spec
35
+
36
+ # Installer logs
37
+ pip-log.txt
38
+ pip-delete-this-directory.txt
39
+
40
+ # Unit test / coverage reports
41
+ htmlcov/
42
+ .tox/
43
+ .nox/
44
+ .coverage
45
+ .coverage.*
46
+ .cache
47
+ nosetests.xml
48
+ coverage.xml
49
+ *.cover
50
+ *.py,cover
51
+ .hypothesis/
52
+ .pytest_cache/
53
+ cover/
54
+
55
+ # Translations
56
+ *.mo
57
+ *.pot
58
+
59
+ # Django stuff:
60
+ *.log
61
+ local_settings.py
62
+ db.sqlite3
63
+ db.sqlite3-journal
64
+
65
+ # Flask stuff:
66
+ instance/
67
+ .webassets-cache
68
+
69
+ # Scrapy stuff:
70
+ .scrapy
71
+
72
+ # Sphinx documentation
73
+ docs/_build/
74
+
75
+ # PyBuilder
76
+ .pybuilder/
77
+ target/
78
+
79
+ # Jupyter Notebook
80
+ .ipynb_checkpoints
81
+
82
+ # IPython
83
+ profile_default/
84
+ ipython_config.py
85
+
86
+ # pyenv
87
+ # For a library or package, you might want to ignore these files since the code is
88
+ # intended to run in multiple environments; otherwise, check them in:
89
+ # .python-version
90
+
91
+ # pipenv
92
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
93
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
94
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
95
+ # install all needed dependencies.
96
+ #Pipfile.lock
97
+
98
+ # poetry
99
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
100
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
101
+ # commonly ignored for libraries.
102
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
103
+ #poetry.lock
104
+
105
+ # pdm
106
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
107
+ #pdm.lock
108
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
109
+ # in version control.
110
+ # https://pdm.fming.dev/#use-with-ide
111
+ .pdm.toml
112
+
113
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
114
+ __pypackages__/
115
+
116
+ # Celery stuff
117
+ celerybeat-schedule
118
+ celerybeat.pid
119
+
120
+ # SageMath parsed files
121
+ *.sage.py
122
+
123
+ # Environments
124
+ .env
125
+ .venv
126
+ env/
127
+ venv/
128
+ ENV/
129
+ env.bak/
130
+ venv.bak/
131
+
132
+ # Spyder project settings
133
+ .spyderproject
134
+ .spyproject
135
+
136
+ # Rope project settings
137
+ .ropeproject
138
+
139
+ # mkdocs documentation
140
+ /site
141
+
142
+ # mypy
143
+ .mypy_cache/
144
+ .dmypy.json
145
+ dmypy.json
146
+
147
+ # Pyre type checker
148
+ .pyre/
149
+
150
+ # pytype static type analyzer
151
+ .pytype/
152
+
153
+ # Cython debug symbols
154
+ cython_debug/
155
+
156
+ # PyCharm
157
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
158
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
159
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
160
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
161
+ .idea/
162
+
@@ -0,0 +1,128 @@
1
+ Spiderweb framework — Development Guidelines
2
+
3
+ 0) What is this?
4
+ Spiderweb is a minimalist Python web framework that blends Django- and Flask-like patterns. It provides function-based views, routing (Flask-style and Django-style, with variable converters), middleware, templating (Jinja2), static files, cookies, sessions, CSRF and CORS middleware, optional Pydantic validation, and a simple built-in WSGI dev server. The codebase targets Python 3.11–3.13.
5
+
6
+ 1) Build/Configuration Instructions
7
+ - Supported Python: 3.11–3.13 (see pyproject.toml). The library itself has minimal runtime deps (peewee, jinja2, cryptography, email-validator, pydantic). Dev tooling uses pytest, hypothesis, coverage, ruff, black.
8
+ - Dependency management:
9
+ - With Poetry (recommended):
10
+ - Install: poetry install
11
+ - Run commands: poetry run python -m spiderweb (if you expose an entry point) or poetry run python example.py
12
+ - Without Poetry:
13
+ - Create venv and install: python -m venv .venv && .venv\Scripts\activate (Windows) or source .venv/bin/activate (POSIX); then pip install -e .[dev]
14
+ Note: If extras aren’t configured, pip install -e . and then pip install the dev tools you need (pytest, coverage, black, ruff).
15
+
16
+ - Running an example app:
17
+ - Minimal app:
18
+ from spiderweb import SpiderwebRouter
19
+ from spiderweb.response import HttpResponse
20
+
21
+ app = SpiderwebRouter(append_slash=True)
22
+
23
+ @app.route("/")
24
+ def index(request):
25
+ return HttpResponse("HELLO, WORLD!")
26
+
27
+ if __name__ == "__main__":
28
+ app.start()
29
+ - Alternatively, run the provided examples: python example.py or python example2.py.
30
+
31
+ - Configuration surface (high-signal items; see SpiderwebRouter.__init__ in spiderweb/main.py):
32
+ - append_slash: If True, auto-redirects /path to /path/ with 301/302 semantics in tests. This affects route matching; be explicit in tests.
33
+ - templates_dirs: List of directories for Jinja2 FileSystemLoader. Required for TemplateResponse with template paths.
34
+ - staticfiles_dirs/static_url: Configure static files serving.
35
+ - allowed_hosts: List or regex patterns for host checking.
36
+ - CORS: cors_* options mirror standard CORS settings, with sane defaults (see constants.py and main.py for defaults and behavior).
37
+ - Sessions/CSRF: session_* options define cookie properties and expiry; CSRF relies on session middleware (ordering matters; see below).
38
+ - DB: pass a Peewee Database (defaults to a local Sqlite file during tests via helpers.setup()).
39
+
40
+ 2) Testing Information
41
+ - Test runner: pytest (configured in pyproject.toml; addopts sets --maxfail=2 -rf).
42
+ - Run all tests: python -m pytest
43
+ - Quiet mode: python -m pytest -q
44
+ - Run a subset by keyword: python -m pytest -k some_keyword
45
+ - Run a specific file (note: when shell path resolution is finicky, prefer -k):
46
+ - python -m pytest -k test_function_name
47
+
48
+ - Coverage:
49
+ - Run: python -m coverage run -m pytest
50
+ - Report: python -m coverage report -m
51
+ - Omit rules: configured in pyproject.toml; conftest.py and spiderweb/tests/* are omitted from coverage.
52
+
53
+ - Project-specific fixtures/helpers:
54
+ - conftest.py defines a session-scoped autouse fixture that deletes spiderweb-tests.db before and after the test session. Do not rely on persistent data between tests.
55
+ - spiderweb.tests.helpers.setup() returns (app, environ, start_response):
56
+ - app is a SpiderwebRouter with a default SqliteDatabase("spiderweb-tests.db").
57
+ - environ is a WSGI environ seeded via wsgiref.util.setup_testing_defaults.
58
+ - start_response is a helper capturing status and headers.
59
+ - Use this to simulate WSGI calls without a real server.
60
+
61
+ - Adding new tests:
62
+ - Place tests under spiderweb/tests, named test_*.py; standard pytest discovery applies.
63
+ - Prefer black/ruff-compliant style; avoid side effects that depend on execution order.
64
+ - For routes, define them on a local SpiderwebRouter instance inside the test to avoid cross-test pollution.
65
+ - Example pattern:
66
+ from spiderweb.response import HttpResponse
67
+ from spiderweb.tests.helpers import setup
68
+
69
+ def test_example():
70
+ app, environ, start_response = setup()
71
+
72
+ @app.route("/ping")
73
+ def ping(request):
74
+ return HttpResponse("pong")
75
+
76
+ environ["PATH_INFO"] = "/ping"
77
+ environ["REQUEST_METHOD"] = "GET"
78
+
79
+ body_iter = app(environ, start_response)
80
+ assert start_response.status.startswith("200")
81
+ assert b"".join(body_iter) == b"pong"
82
+
83
+ - Demo test flow (validated during guideline creation):
84
+ - A temporary test using helpers.setup() and a trivial route was created, executed with python -m pytest -k minimal_route_responds_200 (1 test passed), then removed. This demonstrates the idiomatic testing flow for this codebase.
85
+
86
+ 3) Additional Development Information
87
+ - Code style and tooling:
88
+ - Black (24.8+) and Ruff are configured; run ruff check . and black . to lint/format. CI expects black formatting; badges in README indicate Black usage.
89
+ - Keep functions small and explicit; favor pure functions for components that can be tested without I/O.
90
+
91
+ - Middleware ordering and constraints (important):
92
+ - Session middleware must run before CSRF middleware. Instantiating CSRF without Session middleware, or ordering CSRF above Session, raises configuration errors (see tests in spiderweb/tests/test_middleware.py).
93
+ - GZip middleware has a minimum response length threshold (gzip_minimum_response_length) and will skip small payloads; tests assert that tiny responses are not compressed.
94
+ - CORS middleware honors allow lists, regexes, and credentials flags; ensure preflight (OPTIONS) and actual requests align with cors_allow_methods/headers.
95
+
96
+ - Routing tips:
97
+ - You can mix Flask-style decorators (@app.route("/path")) and Django-style mappings; variable URLs use converters defined in converters.py.
98
+ - append_slash=True triggers redirects to slash-suffixed routes; tests may expect a 301/302 with Location header.
99
+ - Error routes can be overridden via error_routes={code: view} when constructing SpiderwebRouter.
100
+
101
+ - Responses:
102
+ - HttpResponse defaults content-type to text/html; JsonResponse forces application/json and serializes data via json.dumps.
103
+ - TemplateResponse requires either template_path or template_string; if using template_path, ensure templates_dirs is set on the router so the loader can resolve the template.
104
+ - FileResponse sets content-type via mimetypes and streams body as bytes via wsgiref FileWrapper.
105
+
106
+ - Database:
107
+ - spiderweb.db exposes SpiderwebModel. When using a custom Peewee database, pass it into SpiderwebRouter(db=...). In tests, a throwaway Sqlite DB is used via helpers.setup.
108
+
109
+ - Debugging tips:
110
+ - Use the StartResponse helper to inspect status and headers easily: dict(start_response.get_headers()).
111
+ - Examine SpiderwebRouter.prepare_and_fire_response and fire_response for how headers/body are constructed when troubleshooting.
112
+ - Host validation (allowed_hosts) happens per-request; misconfigurations will yield 400/403 depending on tests.
113
+
114
+ - Windows/WSL notes:
115
+ - Paths in docs/tests often assume POSIX; when invoking pytest from Windows shells, prefer selecting tests by -k rather than path strings to avoid escaping issues.
116
+ - The project runs fine under WSL; database file paths are relative to the CWD (see spiderweb-tests.db in conftest).
117
+
118
+ - Releases and versioning:
119
+ - Version is sourced from spiderweb/constants.py and surfaced via __version__ in spiderweb/__init__.py; poetry-bumpversion is configured to update it.
120
+
121
+ 4) Quick checklist for contributors
122
+ - Ensure new middleware documents ordering requirements and provides clear config errors if preconditions aren’t met.
123
+ - Add tests for:
124
+ - Success and failure paths
125
+ - Edge cases (empty bodies, small vs large responses for GZip, invalid cookie attributes)
126
+ - Redirect and header semantics (Location, Set-Cookie, Content-Type)
127
+ - Run: python -m pytest and, optionally, coverage to keep coverage high.
128
+ - Keep temporary files out of the repo; tests should not write outside the project root and should clean up after themselves.
@@ -1,48 +1,48 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 Joe Kaufeld
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
22
-
23
- ---
24
-
25
- Substantial portions of spiderweb/middleware/cors.py and docs/middleware/cors.md
26
- are from django-cors-headers and are subject to the following license:
27
-
28
- MIT License
29
-
30
- Copyright (c) 2017 Otto Yiu (https://ottoyiu.com) and other contributors.
31
-
32
- Permission is hereby granted, free of charge, to any person obtaining a copy
33
- of this software and associated documentation files (the "Software"), to deal
34
- in the Software without restriction, including without limitation the rights
35
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
36
- copies of the Software, and to permit persons to whom the Software is
37
- furnished to do so, subject to the following conditions:
38
-
39
- The above copyright notice and this permission notice shall be included in all
40
- copies or substantial portions of the Software.
41
-
42
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
43
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
44
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
45
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
46
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
47
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
48
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Joe Kaufeld
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ ---
24
+
25
+ Substantial portions of spiderweb/middleware/cors.py and docs/middleware/cors.md
26
+ are from django-cors-headers and are subject to the following license:
27
+
28
+ MIT License
29
+
30
+ Copyright (c) 2017 Otto Yiu (https://ottoyiu.com) and other contributors.
31
+
32
+ Permission is hereby granted, free of charge, to any person obtaining a copy
33
+ of this software and associated documentation files (the "Software"), to deal
34
+ in the Software without restriction, including without limitation the rights
35
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
36
+ copies of the Software, and to permit persons to whom the Software is
37
+ furnished to do so, subject to the following conditions:
38
+
39
+ The above copyright notice and this permission notice shall be included in all
40
+ copies or substantial portions of the Software.
41
+
42
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
43
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
44
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
45
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
46
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
47
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
48
+ SOFTWARE.
@@ -1,29 +1,28 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: spiderweb-framework
3
- Version: 1.4.0
3
+ Version: 2.0.1
4
4
  Summary: A small web framework, just big enough for a spider.
5
- License: LICENSE.txt
6
- Author: Joe Kaufeld
7
- Author-email: opensource@joekaufeld.com
8
- Requires-Python: >=3.11,<4.0
5
+ Project-URL: Homepage, https://github.com/itsthejoker/spiderweb
6
+ Project-URL: Documentation, https://github.com/itsthejoker/spiderweb
7
+ Project-URL: Repository, https://git.joekaufeld.com/jkaufeld/spiderweb
8
+ Project-URL: Bug Tracker, https://github.com/itsthejoker/spiderweb/issues
9
+ Author-email: Joe Kaufeld <opensource@joekaufeld.com>
10
+ License-Expression: MIT
11
+ License-File: LICENSE.txt
9
12
  Classifier: Development Status :: 4 - Beta
10
13
  Classifier: Environment :: Web Environment
11
14
  Classifier: Intended Audience :: Developers
12
- Classifier: License :: Other/Proprietary License
13
- Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3 :: Only
14
16
  Classifier: Programming Language :: Python :: 3.11
15
17
  Classifier: Programming Language :: Python :: 3.12
16
18
  Classifier: Programming Language :: Python :: 3.13
17
- Classifier: Programming Language :: Python :: 3 :: Only
18
19
  Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
19
20
  Classifier: Topic :: Internet :: WWW/HTTP :: WSGI
20
21
  Classifier: Topic :: Internet :: WWW/HTTP :: WSGI :: Application
21
22
  Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
22
- Requires-Dist: cryptography (>=43.0.0,<44.0.0)
23
- Requires-Dist: email-validator (>=2.2.0,<3.0.0)
24
- Requires-Dist: jinja2 (>=3.1.4,<4.0.0)
25
- Requires-Dist: peewee (>=3.17.6,<4.0.0)
26
- Requires-Dist: pydantic (>=2.8.2,<3.0.0)
23
+ Requires-Dist: advanced-alchemy<2.0.0,>=1.6.3
24
+ Provides-Extra: pydantic
25
+ Requires-Dist: pydantic<3,>=2.8.2; extra == 'pydantic'
27
26
  Description-Content-Type: text/markdown
28
27
 
29
28
  # spiderweb
@@ -50,7 +49,9 @@ So I built one.
50
49
  `spiderweb` is a small web framework, just big enough to hold a spider. Getting started is easy:
51
50
 
52
51
  ```shell
53
- poetry add spiderweb-framework
52
+ uv add spiderweb-framework
53
+ # or
54
+ pip install spiderweb-framework
54
55
  ```
55
56
 
56
57
  Create a new file and drop this in it:
@@ -71,6 +72,17 @@ if __name__ == "__main__":
71
72
 
72
73
  ## [View the docs here!](https://itsthejoker.github.io/spiderweb/#/)
73
74
 
75
+ ### Development (using uv)
76
+
77
+ This repository uses uv for local development and testing.
78
+
79
+ - Create a virtual environment: `uv venv`
80
+ - Activate it (Windows): `.venv\Scripts\activate`
81
+ - Activate it (POSIX): `source .venv/bin/activate`
82
+ - Install deps (editable + dev): `uv pip install -e .[dev]`
83
+ - Run tests: `uv run python -m pytest`
84
+ - Lint/format: `uv run ruff check .` and `uv run black .`
85
+
74
86
  My goal with this framework was to do three things:
75
87
 
76
88
  1. Learn a lot
@@ -96,6 +108,5 @@ And, honestly, I think I got there. Here's a non-exhaustive list of things this
96
108
  - CORS middleware
97
109
  - Optional POST data validation middleware with Pydantic
98
110
  - Session middleware with built-in session store
99
- - Database support (using Peewee, but you can use whatever you want as long as there's a Peewee driver for it)
111
+ - Database support (using SQLAlchemy, but you can use whatever you want as long as there's a SQLAlchemy driver for it)
100
112
  - Tests (currently roughly 89% coverage)
101
-
@@ -1,72 +1,85 @@
1
- # spiderweb
2
-
3
- <p align="center">
4
- <img
5
- src="https://img.shields.io/pypi/v/spiderweb-framework.svg?style=for-the-badge"
6
- alt="PyPI release version for Spiderweb"
7
- />
8
- <img
9
- src="https://img.shields.io/badge/gitmoji-%20😜%20😍-FFDD67.svg?style=for-the-badge"
10
- alt="Gitmoji"
11
- />
12
- <img
13
- src="https://img.shields.io/badge/code%20style-black-000000.svg?style=for-the-badge"
14
- alt="Code style: Black"
15
- />
16
- </p>
17
-
18
- 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_.
19
-
20
- So I built one.
21
-
22
- `spiderweb` is a small web framework, just big enough to hold a spider. Getting started is easy:
23
-
24
- ```shell
25
- poetry add spiderweb-framework
26
- ```
27
-
28
- Create a new file and drop this in it:
29
-
30
- ```python
31
- from spiderweb import SpiderwebRouter
32
- from spiderweb.response import HttpResponse
33
-
34
- app = SpiderwebRouter()
35
-
36
- @app.route("/")
37
- def index(request):
38
- return HttpResponse("HELLO, WORLD!")
39
-
40
- if __name__ == "__main__":
41
- app.start()
42
- ```
43
-
44
- ## [View the docs here!](https://itsthejoker.github.io/spiderweb/#/)
45
-
46
- My goal with this framework was to do three things:
47
-
48
- 1. Learn a lot
49
- 2. Create an unholy blend of Django and Flask
50
- 3. Not look at any existing code. Go off of vibes alone and try to solve all the problems I could think of in my own way
51
-
52
- And, honestly, I think I got there. Here's a non-exhaustive list of things this can do:
53
-
54
- - Function-based views
55
- - Optional Flask-style URL routing
56
- - Optional Django-style URL routing
57
- - URLs with variables in them a lá Django
58
- - Full middleware implementation
59
- - Limit routes by HTTP verbs
60
- - Custom error routes
61
- - Built-in dev server
62
- - Gunicorn support
63
- - HTML templates with Jinja2
64
- - Static files support
65
- - Cookies (reading and setting)
66
- - Optional append_slash (with automatic redirects!)
67
- - CSRF middleware
68
- - CORS middleware
69
- - Optional POST data validation middleware with Pydantic
70
- - Session middleware with built-in session store
71
- - Database support (using Peewee, but you can use whatever you want as long as there's a Peewee driver for it)
72
- - Tests (currently roughly 89% coverage)
1
+ # spiderweb
2
+
3
+ <p align="center">
4
+ <img
5
+ src="https://img.shields.io/pypi/v/spiderweb-framework.svg?style=for-the-badge"
6
+ alt="PyPI release version for Spiderweb"
7
+ />
8
+ <img
9
+ src="https://img.shields.io/badge/gitmoji-%20😜%20😍-FFDD67.svg?style=for-the-badge"
10
+ alt="Gitmoji"
11
+ />
12
+ <img
13
+ src="https://img.shields.io/badge/code%20style-black-000000.svg?style=for-the-badge"
14
+ alt="Code style: Black"
15
+ />
16
+ </p>
17
+
18
+ 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_.
19
+
20
+ So I built one.
21
+
22
+ `spiderweb` is a small web framework, just big enough to hold a spider. Getting started is easy:
23
+
24
+ ```shell
25
+ uv add spiderweb-framework
26
+ # or
27
+ pip install spiderweb-framework
28
+ ```
29
+
30
+ Create a new file and drop this in it:
31
+
32
+ ```python
33
+ from spiderweb import SpiderwebRouter
34
+ from spiderweb.response import HttpResponse
35
+
36
+ app = SpiderwebRouter()
37
+
38
+ @app.route("/")
39
+ def index(request):
40
+ return HttpResponse("HELLO, WORLD!")
41
+
42
+ if __name__ == "__main__":
43
+ app.start()
44
+ ```
45
+
46
+ ## [View the docs here!](https://itsthejoker.github.io/spiderweb/#/)
47
+
48
+ ### Development (using uv)
49
+
50
+ This repository uses uv for local development and testing.
51
+
52
+ - Create a virtual environment: `uv venv`
53
+ - Activate it (Windows): `.venv\Scripts\activate`
54
+ - Activate it (POSIX): `source .venv/bin/activate`
55
+ - Install deps (editable + dev): `uv pip install -e .[dev]`
56
+ - Run tests: `uv run python -m pytest`
57
+ - Lint/format: `uv run ruff check .` and `uv run black .`
58
+
59
+ My goal with this framework was to do three things:
60
+
61
+ 1. Learn a lot
62
+ 2. Create an unholy blend of Django and Flask
63
+ 3. Not look at any existing code. Go off of vibes alone and try to solve all the problems I could think of in my own way
64
+
65
+ And, honestly, I think I got there. Here's a non-exhaustive list of things this can do:
66
+
67
+ - Function-based views
68
+ - Optional Flask-style URL routing
69
+ - Optional Django-style URL routing
70
+ - URLs with variables in them a lá Django
71
+ - Full middleware implementation
72
+ - Limit routes by HTTP verbs
73
+ - Custom error routes
74
+ - Built-in dev server
75
+ - Gunicorn support
76
+ - HTML templates with Jinja2
77
+ - Static files support
78
+ - Cookies (reading and setting)
79
+ - Optional append_slash (with automatic redirects!)
80
+ - CSRF middleware
81
+ - CORS middleware
82
+ - Optional POST data validation middleware with Pydantic
83
+ - Session middleware with built-in session store
84
+ - Database support (using SQLAlchemy, but you can use whatever you want as long as there's a SQLAlchemy driver for it)
85
+ - Tests (currently roughly 89% coverage)
@@ -0,0 +1,12 @@
1
+ import os
2
+
3
+ from pytest import fixture
4
+
5
+
6
+ @fixture(autouse=True, scope="session")
7
+ def db():
8
+ if os.path.exists("spiderweb-tests.db"):
9
+ os.remove("spiderweb-tests.db")
10
+ yield
11
+ if os.path.exists("spiderweb-tests.db"):
12
+ os.remove("spiderweb-tests.db")