A learning opportunity for a web framework.
Go to file
2024-08-25 00:04:29 -04:00
spiderweb session middleware and databases! 2024-08-25 00:04:29 -04:00
static_files staticfiles support\! 2024-08-14 19:27:37 -04:00
templates convert to wsgi with gunicorn support 2024-08-18 17:45:38 -04:00
.gitignore 🎉 first commit 2024-07-28 20:46:42 -04:00
example2.py add pydantic middleware 2024-08-21 21:07:44 -04:00
example_middleware.py 🎨 run black 2024-08-14 17:28:01 -04:00
example.py session middleware and databases! 2024-08-25 00:04:29 -04:00
LICENSE.txt 📄 add license 2024-08-23 22:17:21 -04:00
poetry.lock session middleware and databases! 2024-08-25 00:04:29 -04:00
pyproject.toml 📄 add license 2024-08-23 22:17:21 -04:00
README.md 📝 add basic information to readme 2024-08-21 22:31:21 -04:00

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:

  1. Learn a lot
  2. Create an unholy blend of Django and Flask
  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

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

The TODO list:

  • Tests (important)
  • Database support
  • Session middleware
  • Fix CSRF middleware once database support is included

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.