Skip to main content

Curio-based web framework

Project description


A Curio HTTP server.


Trinket requires python3.7+

git clone
python3.7 -m venv trinket_env
source trinket_env/bin/activate
pip install -e trinket trinket[test]
pytest trinket/tests


from trinket import Trinket, Response
from trinket.response import file_iterator
from trinket.extensions import logger

bauble = logger(Trinket())

async def hello(request):
    return Response.raw(b'Hello World !')

@bauble.route('/raw', methods=['POST'])
async def raw(request):
    return Response.raw(b'You got here')

@bauble.route('/read', methods=['POST'])
async def reader(request):
    await request.parse_body()
    files = list(request.files.keys())
    return Response.raw("You got here and it's all read: {}".format(files))

async def json(request, one, two):
    response = Response.json({
        'parameters': f'{one} and {two}',
        'query': request.query.get('query'),
        'cookie': request.cookies['test'],
    response.cookies.set(name='bench', value='value')
    return response

async def serve_websocket(request):
    response = Response.streamer(file_iterator('myfile.ext'))
    return response

async def chat(request, websocket):
    while True:
        msg = await websocket.recv()
        for ws in bauble.websockets:
            if ws is not websocket:
                await ws.send(msg)



Trinket relies heavily on packages from very good re-useable components with Cython-improved performances.


0.1.5 (2019-12-18)

  • Fixed body duplication on raw_body calls, due to the concatenation already happening in on_body, triggered by the reader.

0.1.4 (2019-12-16)

  • Dependencies maintenance : bumping versions to latest stable.

0.1.3 (2019-01-24)

  • Pinned specific package versions
  • Updated to use the last version of wsproto (0.13)
  • The Trinket application now inherits from dict to allow arbitrary storage
  • Decoupled the TCP serving/socket creation from the actual application

0.1.2 (2019-01-18)

  • Updated distribution files

0.1.1 (2019-01-18)

  • Added tests and testing utilities
  • Fixed missing imports

0.1 (2019-01-17)

  • Initial release

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

trinket-0.1.5.tar.gz (19.4 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page