Skip to main content

Receive

receive is a python library for hosting temporary web servers and receiving values from their route handlers via futures.

Install

Stable Release

pip install receive

Latest Features

pip install git+https://github.com/BlakeASmith/receive

Usage

Handle a GET request

First, define a route handler as follows:

import receive

@receive.get_request(route="/callback", port=5000)
async def get_query_param_from_request(req):
    return req.query["code"]

The req parameter is an aiohttp.web.Request object. In this example we return the code query parameter from the request.

Now we can start a temporary web server, and get our return value from the first request that comes in.

import asyncio

async def main():
    future = await get_query_param_from_request()
    code = await future
    print(code)
    
    
if __name__ == "__main__":
    asyncio.get_event_loop().run_until_complete(main)

The get_query_param_from_request function will start a web server in the background and return a asyncio.Future object providing access to the return value from the handler. get_query_param_from_request will return immediately, and invoking await on the returned future will block until a GET 0.0.0.0:5000/callback request hits the server. At that time the future will be completed with the value returned from the request handler and the server will be shutdown.

Tests

Run the unit tests using pytest

poetry install
poetry run pytest

Release files for receive 0.1.1

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

Source distribution (sdist)

Source distribution for receive 0.1.1
File Size Uploaded
receive-0.1.1.tar.gz 2.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for receive 0.1.1
File Interpreter ABI Platform
receive-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 4.9 kB

Release files / receive-0.1.1.tar.gz

Download URL receive-0.1.1.tar.gz
Size 2.4 kB
Tags Source
SHA-256 checksum
How to use checksums
d0c5e715c07cd8c317ce09bd0dc32f405e62067a041e80c9133d790aafc9b2aa
BLAKE2b-256 checksum
How to use checksums
03f132cf78fa83c3709a32c8a4d5157681c695334f06df9a5d769a0e96ccd6f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.6 CPython/3.9.5 Linux/5.4.0-1047-azure

Release files / receive-0.1.1-py3-none-any.whl

Download URL receive-0.1.1-py3-none-any.whl
Size 2.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9b03d1e83fef03d4f8bd5ee5724c54107848c8d6f1eb8c7d27da39bb10c2a89d
BLAKE2b-256 checksum
How to use checksums
7461e5ceda82b950ed9f276530fd6fb64b74291c12654c3b3f2ef2daf56a1032
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.6 CPython/3.9.5 Linux/5.4.0-1047-azure

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

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