pgjonesquart: Official mirror of https | quart python
QuartisanasyncPythonwebmicroframework.UsingQuartyoucan,renderandserveHTMLtemplates,write(RESTful)JSONAPIs,serveWebSockets,streamrequestandresponsedata,doprettymuchanythingovertheHTTPorWebSocketprotocols.QuickstartQuartcanbeinstalledviapip[1],andrequiresPython3.7.0orhigher(seepythonversionsupport[2]forreasoning).AminimalQuartexampleis,fromquartimportQuart,render_template,websocketapp=Quart(__name__)@app.route("/")asyncdefhello():returnawaitrender_template("index.html")@app.route("/api")asyncd...
Quart is an async Python web microframework. Using Quart you can,
render and serve HTML templates, write (RESTful) JSON APIs, serve WebSockets, stream request and response data, do pretty much anything over the HTTP or WebSocket protocols. QuickstartQuart can be installed via pip[1],
and requires Python 3.7.0 or higher (see python version support[2] for reasoning).
A minimal Quart example is,
from quart import Quart, render_template, websocket app = Quart(__name__) @app.route("/") async def hello(): return await render_template("index.html") @app.route("/api") async def json(): return {"hello": "world"} @app.websocket("/ws") async def ws(): while True: await websocket.send("hello") await websocket.send_json({"hello": "world"}) if __name__ == "__main__": app.run()if the above is in a file called app.py it can be run as...