Python sync/async client for the WebMediator API
Project description
webmediator 
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())
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)
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())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
webmediator-1.0.5.tar.gz
(8.1 kB
view details)
File details
Details for the file webmediator-1.0.5.tar.gz.
File metadata
- Download URL: webmediator-1.0.5.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cff1dea6ca5461359d4b7e3d071aea7072fd320e8f0fd07084f40e45c0684482
|
|
| MD5 |
a4253ec5fcd232515f48bc89894dc097
|
|
| BLAKE2b-256 |
5f1eaba1989a7eb8b13bc3fc5633f1b18754ad6e915aa67c7d30b5e0c6298751
|