A basic networking layer with async callbacks


License
MIT
Install
pip install jm-networking==1.0.17

Documentation

jm-networking

Basic networking layer with async callbacks

Requires Python 3

Installation

pip install jm-networking

Latest version is 1.0.12

Example Usage

  from jm_networking import Network

  def success_callback(result):
      print("Execute success callback")

  def failure_callback(result):
      print("Execute failure callback")

  with Network() as network:
      network.on_success(success_callback)
      network.on_failure(failure_callback)
      network.get("https://example.com")

Other HTTP methods

    ...
    network.post("https://example.com", {body: data})
    
    ...
    network.put("https://example.com", {body: data})
    
    ...
    network.delete("https://example.com")

Return response from callback (e.g. to return response to screen or render template in Flask)

  def success_callback(result):
      return "Response"

  with Network() as network:
      network.on_success(success_callback)
      return network.get("https://example.com")

"Response"