Starlette includes support for HTTP/2 and HTTP/3 server push, making itpossible to push resources to the client to speed up page load times.
Used to initiate a server push for a resource. If server push is not availablethis method does nothing.
fromstarlette.applicationsimportStarlettefromstarlette.responsesimportHTMLResponsefromstarlette.routingimportRoute,Mountfromstarlette.staticfilesimportStaticFilesasyncdefhomepage(request):""" Homepage which uses server push to deliver the stylesheet. """awaitrequest.send_push_promise("/static/style.css")returnHTMLResponse('<html><head><link rel="stylesheet" href="/static/style.css"/></head></html>')routes=[Route("/",endpoint=homepage),Mount("/static",StaticFiles(directory="static"),name="static")]app=Starlette(routes=routes)