Skip to main content

webmediator PyPI version

Python sync/async client for the WebMediator API.

pip install webmediator

Example 1: request/response

import webmediator

client = webmediator.Client('https://localhost:7263/mediator')

response = client.send('Ping', {'message':'EXAMPLE' })
print(response)

Console output:

type: Pong, data: {'message': 'EXAMPLE PONG'}

Example 2: Async request/response

import webmediator
import asyncio

async def main():
    client = webmediator.AsyncClient('http://localhost:5263/mediator')

    response = await client.send('Ping', {'message':'EXAMPLE' })
    print(response)

if __name__ == "__main__":
    asyncio.get_event_loop().run_until_complete(main())

More code...

Example 3: File upload/download

import webmediator

client = webmediator.Client('https://localhost:7263/mediator')

with open('example.txt','rb') as file: 
    client.send('FileUpload', { 'name': file.name, 'content': file })

with client.send('FileDownload', { 'name': file.name }) as response:
    content = response.data.read()
    print(content)

More code...

Example 4: Server-sent events

import webmediator
import asyncio

async def main():
    client = webmediator.AsyncClient('http://localhost:5263/mediator')

    async for sse in client.event_stream('ExampleAsyncEvents'):
        print(sse)

if __name__ == "__main__":
    asyncio.get_event_loop().run_until_complete(main())

More code...

Metadata

Release files for webmediator 1.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for webmediator 1.0.5
File Size Uploaded
webmediator-1.0.5.tar.gz 8.1 kB Details

Release files / webmediator-1.0.5.tar.gz

Download URL webmediator-1.0.5.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
cff1dea6ca5461359d4b7e3d071aea7072fd320e8f0fd07084f40e45c0684482
BLAKE2b-256 checksum
How to use checksums
5f1eaba1989a7eb8b13bc3fc5633f1b18754ad6e915aa67c7d30b5e0c6298751
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.2

Release history Release notifications | RSS feed

This release

1.0.5 This release

1 release file

1.0.3

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

0.9.6

1 release file

0.9.5

1 release file

0.9.4

1 release file

0.9.2

1 release file

0.9.1

1 release file

0.9.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page