[HN Gopher] BlackSheep: Fast ASGI web framework for Python
       ___________________________________________________________________
        
       BlackSheep: Fast ASGI web framework for Python
        
       Author : klaussilveira
       Score  : 27 points
       Date   : 2024-12-18 16:58 UTC (6 hours ago)
        
 (HTM) web link (github.com)
 (TXT) w3m dump (github.com)
        
       | Majestic121 wrote:
       | What is the plus value vs a 'classical' equivalent like FastAPI ?
        
         | scrollaway wrote:
         | So as far as I can tell, this is basically a more modern Flask.
         | It pulls in design lessons from FastAPI, but it's still more
         | batteries included such as templating (jinja2) and
         | authentication.
         | 
         | Neat, but tbh I am very bearish on Python's future beyond APIs
         | - templating html in Python is a terrible idea for anything
         | larger than a hobby site, when you can have an API-first app
         | with a React+Typescript frontend.
         | 
         | And if you need more than FastAPI, you might as well use
         | django-ninja and get the full Django ecosystem at your
         | disposal.
        
           | kaedroho wrote:
           | For Django, there's also django-bridge. This lets you build
           | React apps that are backed by Django views/routing. You can
           | also use Django's built-in authentication and forms which
           | isn't easy with APIs.
        
       | adamredwoods wrote:
       | I was trying to see the value of this as well, but I don't know
       | Python well enough. Maybe there is no ASGI for python?
       | 
       | And I assume Python cannot handle it's own HTTP server (using
       | threads, similar to Javalin's virtual threads)? I always cringe
       | when a programming language needs to find another
       | solution/language to handling its processes. I understand why you
       | will need a load balancer, but for small, simple projects, I like
       | to contain things.
        
         | miohtama wrote:
         | Python has had threaded, multiprocessing and such web servers
         | for 20 years now e.g. in the form of Apache's mod_wsgi.
         | 
         | The async movement is recent, and optional in Python. There are
         | benefits for async, but obvious downsides line coloured
         | functions.
        
           | LudwigNagasena wrote:
           | There is no true function colouring in Python. You can do
           | `asyncio.run(async_function())` inside almost any sync
           | function, or provide your own async shim.
        
             | anentropic wrote:
             | "async def" is literally function colouring
        
         | jna_sh wrote:
         | > And I assume Python cannot handle it's own HTTP server (using
         | threads, similar to Javalin's virtual threads)?
         | 
         | ASGI is an Interface standard, not an implementation in another
         | language. The AGSI compliant servers that Blacksheep recommends
         | are both written in Python.
        
           | runjake wrote:
           | Nitpick: If you're going to use ASGI with Flask, consider
           | using Quart[1] instead[2], which aims to be Flask with better
           | async.
           | 
           | 1. https://quart.palletsprojects.com/en/latest/
           | 
           | 2. https://flask.palletsprojects.com/en/stable/async-
           | await/#asy...
        
         | stackskipton wrote:
         | There is plenty. FastAPI, Starlite and Flask are all ASGI.
         | 
         | Yes, Python has its own ASGI HTTP Servers, Uvicorn and
         | Hypercorn are two most common.
         | 
         | I agree, I'm not sure what this project aims to fix over other
         | more established projects.
        
         | dec0dedab0de wrote:
         | ASGI, and WSGI before it are standard interfaces for python web
         | traffic.
         | 
         | it allows you to write an application (or in this case a
         | framework) and have it work with multiple application
         | webservers. I don't know if java has an equivalent, but imagine
         | if you could switch from tomcat to something else without
         | changing any application code.
        
         | anentropic wrote:
         | from the README:
         | 
         | > BlackSheep belongs to the category of ASGI web frameworks, so
         | it requires an ASGI HTTP server to run, such as uvicorn, or
         | hypercorn.
         | 
         | but uvicorn and hypercorn are both Python libraries
         | 
         | so no need to cringe
        
       | urduntupu wrote:
       | Another ASGI web framework mimicking the Flask API:
       | https://github.com/pallets/quart/
        
       ___________________________________________________________________
       (page generated 2024-12-18 23:00 UTC)