A learning opportunity for a web framework.
Go to file
2024-09-09 01:47:23 -04:00
docs 📝 fix docs error 2024-09-09 01:47:23 -04:00
spiderweb 🔖 release 1.1.0 2024-09-09 01:44:09 -04:00
static_files staticfiles support\! 2024-08-14 19:27:37 -04:00
templates 🚧 add groundwork for origins 2024-08-30 20:34:43 -04:00
.gitignore 🎉 first commit 2024-07-28 20:46:42 -04:00
conftest.py Testing! 2024-08-26 01:56:08 -04:00
example2.py Testing! 2024-08-26 01:56:08 -04:00
example_middleware.py 🎨 run black 2024-08-14 17:28:01 -04:00
example.py 📝 add missing info about error routes 2024-09-03 01:37:57 -04:00
LICENSE.txt 📄 update license 2024-09-02 00:38:19 -04:00
poetry.lock Testing! 2024-08-26 01:56:08 -04:00
pyproject.toml 🔖 release 1.1.0 2024-09-09 01:44:09 -04:00
README.md 📝 update README 2024-09-03 01:20:04 -04:00
test.py 📝 first push of docs 2024-08-26 01:56:56 -04:00

spiderweb

PyPI release version for Spiderweb Gitmoji Code style: Black

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:

  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
  • 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 roughly 89% coverage)