A small web framework, just big enough for a spider.
Project description
spiderweb
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.
So I built one.
spiderweb
is a small web framework, just big enough to hold a spider. Getting started is easy:
poetry add spiderweb-framework
Create a new file and drop this in it:
from spiderweb import SpiderwebRouter
from spiderweb.response import HttpResponse
app = SpiderwebRouter()
@app.route("/")
def index(request):
return HttpResponse("HELLO, WORLD!")
if __name__ == "__main__":
app.start()
My goal with this framework was to do three things:
- Learn a lot
- Create an unholy blend of Django and Flask
- 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
And, honestly, I think I got there. Here's a non-exhaustive list of things this can do:
- Function-based views
- Optional Flask-style URL routing
- Optional Django-style URL routing
- URLs with variables in them a lá Django
- Gunicorn support
- Full middleware implementation
- Limit routes by HTTP verbs
- Custom error routes
- Built-in dev server
- HTML templates with Jinja2
- Static files support
- Cookies (reading and setting)
- Optional append_slash (with automatic redirects!)
CSRF middleware implementation(it's there, but it's crappy and unsafe. I'm working on it.)- Optional POST data validation middleware with Pydantic
- Database support (using Peewee, but the end user can use whatever they want as long as there's a Peewee driver for it)
- Session middleware
The TODO list:
- Tests (important)
- Fix CSRF middleware
Once tests are in and proven to work, then I'll release as version 1.0.
More documentation to follow!
If you're reading this on GitHub, this repository is a public mirror of https://git.joekaufeld.com/jkaufeld/spiderweb.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for spiderweb_framework-0.12.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 297f6113cf81909a21ba98bb1f9ca7cd0a3c8aa2a2c5a4b4a75839adf0c752ee |
|
MD5 | bddd3d11961035706474ca32a7bbbb47 |
|
BLAKE2b-256 | 32ba299c0406ef7dc4c10d0a7a6b889990ac44fd998f170792a7d52d8b66bcd2 |
Hashes for spiderweb_framework-0.12.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8186ff1cfe94c3c9cae085bb3be23f7ea5ed43dc08680cb0755a62231623bcb9 |
|
MD5 | 57aecd36f0b0031fee65b3bc817bb720 |
|
BLAKE2b-256 | 8c7f4d7cf3694a8293b059677f359bf4e73db1df8dca9a04575608938a6559b8 |