DEV Community

Ciro Spaciari
Ciro Spaciari

Posted on

Adding better DX to the fastest Python WebFramework

After more than a year of active development, I finally publish my package to PyPI!

pip install socketify
Enter fullscreen mode Exit fullscreen mode

After some people asks to also create a WSGI and ASGI server to improve projects using other frameworks, I worked hard to get it right.

But in the end, we outperform uvicorn and meinheld with Flask, Django, Emmett, FastAPI, and Falcon in TechEmPower plaintext with our WSGI and ASGI servers!

And we got the Top 1 with socketify itself!

Also added a CLI tool with very familiar options for uvicorn and gunicorn users


Also added lifespan (start and shutdown) events to socketify itself, and added an improved DX for routing and support to Extensions/Plugins.

from socketify import App

def run(app: App):
    async def on_start():
        # we can start connection pools here

    async def on_shutdown():
        # and here we can clean connection pools

    router = app.router()
    api = app.router(prefix="/api")
    private = app.router("/api", auth_middleware)

    def home(res, req):
        res.send("Hello, World!")

    # will serve in /api/hello
    def hello(res, req):
       res.send("Hello API!")

    # will serve in /api/users and use auth_middleware
    def get_users(res, req, auth):
       res.send("Hello private API!")
Enter fullscreen mode Exit fullscreen mode
 python3 -m socketify main:run --port 8080 --workers 2
Enter fullscreen mode Exit fullscreen mode

About Extensions:

My focus until v0.1.0 now will be to add features to help developers and add more optimizations.

Are there any features that you want to see in the future? I will love to get community feedback!


Issues and Planned Features:


Top comments (0)