27.11.2017       Выпуск 206 (27.11.2017 - 03.12.2017)       Интересные проекты, инструменты, библиотеки

quart - asyncio framework аля Flask

Читать>>



Экспериментальная функция:

Ниже вы видите текст статьи по ссылке. По нему можно быстро понять ссылка достойна прочтения или нет

Просим обратить внимание, что текст по ссылке и здесь может не совпадать.

README.rst

Quart

Build Status docs pypi http

Quart is a Python asyncio web microframework with the same API as Flask. Quart should provide a very minimal step to use Asyncio in a Flask app. See the docs.

Quart extends the Flask-API by adding support for

  • HTTP/1.1, including chunked transfer-encoded requests and pipelining.
  • Websockets.
  • HTTP/2, including the ability to server push.

Quickstart

Quart can be installed via pip pip install quart and requires Python 3.6+. A minimal Quart example would be

from quart import Quart, websocket

app = Quart(__name__)

@app.route('/')
async def hello():
    return 'hello'

@app.websocket('/ws')
async def ws():
    while True:
        await websocket.send('hello')

app.run()

if the above is in a file called app.py can be run via python app.py. To deploy in a production setting see the docs.

API Compatibility with Flask

The Flask API can be described as consisting of the Flask public and private APIs and Werkzeug upon which Flask is based. Quart is designed to be fully compatible with the Flask public API (aside from async and await keywords). Thereafter the aim is to be mostly compatible with the Flask private API and to provide no guarantees about the Werkzeug API.

Migrating from Flask

It should be possible to migrate to Quart from Flask by a find and replace of flask to quart and then adding async and await keywords. See the docs for full details.



Лучшая Python рассылка

Нас поддерживает


Python Software Foundation



Разместим вашу рекламу

Пиши: mail@pythondigest.ru

Нашли опечатку?

Выделите фрагмент и отправьте нажатием Ctrl+Enter.

Система Orphus