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()
View the docs here!
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
- Full middleware implementation
- Limit routes by HTTP verbs
- Custom error routes
- Built-in dev server
- Gunicorn support
- HTML templates with Jinja2
- Static files support
- Cookies (reading and setting)
- Optional append_slash (with automatic redirects!)
- CSRF middleware
- CORS middleware
- Optional POST data validation middleware with Pydantic
- Session middleware with built-in session store
- Database support (using Peewee, but you can use whatever you want as long as there's a Peewee driver for it)
- Tests (currently a little over 80% coverage)
Once tests are in and proven to work, then I'll release as version 1.0.
- currently missing tests for cors middleware
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-1.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | baa0bc52a2c7a56d4ddf9830f52de2c06c279464212df8ffe9183d997c7f5356 |
|
MD5 | 2c27051952494eb01b4380bf41f38750 |
|
BLAKE2b-256 | 7ee53286bc208f652e7b935d51039b7e8fb65e1873cb192e8afc91a3568273b0 |
Hashes for spiderweb_framework-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf679308ea42f513cfa9bd8b1f642f8366964ac796719b36179b34bb90bb7a50 |
|
MD5 | 648909c3ed6c810e53d42f53ac358cbe |
|
BLAKE2b-256 | 6b06ceae05c5a71b2e98c61def98e506f83f108ef4074a942ac7da8e4c3e4e93 |