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.11.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17bec32c4f5abbbcb1e746f45bd82b5c195e78b7acb42cb223219ecbbf5de923 |
|
MD5 | 4d1372ff77c0485fa5be5c6a26e7ad35 |
|
BLAKE2b-256 | 4a451a6bd527bb738e0762356c81163f45c8ad5e87fb0434bb99fc64abde8acc |
Hashes for spiderweb_framework-0.11.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d8783d5a839f991594dd32d4f93cfb5a5f6cc95e9915673ec701fcb8e0701ff |
|
MD5 | 774226ec770a3258c3fadd10a21d035c |
|
BLAKE2b-256 | 4a489ed35167095232b2be9dfe2a7d759697032909f542a9c5fd59c05045805c |