Skip to main content

REST tools in python - common code for client and server

Project description

PyPI GitHub release (latest by date including pre-releases) PyPI - License Lines of code GitHub issues GitHub pull requests

rest-tools

This project contains REST tools in python, as common code for multiple other projects under https://github.com/WIPACrepo.

All code uses python asyncio, so is fully asyncronous.

Note that both the client and server assume starting the asyncio loop happens elsewhere - they do not start the loop themselves.

Client

A REST API client exists under rest_tools.client. Use as:

    from rest_tools.client import RestClient

    api = RestClient('http://my.site.here/api', token='XXXX')
    ret = await api.request('GET', '/fruits/apple')
    ret = await api.request('POST', '/fruits', {'name': 'banana'})

Server

A REST API server exists under rest_tools.server. Use as:

    import asyncio
    from rest_tools.server import RestServer, RestHandler

    class Fruits(RestHandler):
        def post(self):
            # handle a new fruit
            self.write({})

    server = RestServer()
    server.add_route('/fruits', Fruits)
    server.startup(address='my.site.here', port=8080)
    asyncio.get_event_loop().run_forever()

The server uses Tornado to handle HTTP connections. It is recommended to use Apache or Nginx as a front-facing proxy, to handle TLS sessions and non-standard HTTP requests in production.

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

wipac-rest-tools-1.3.12.tar.gz (22.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wipac_rest_tools-1.3.12-py3-none-any.whl (25.2 kB view details)

Uploaded Python 3

File details

Details for the file wipac-rest-tools-1.3.12.tar.gz.

File metadata

  • Download URL: wipac-rest-tools-1.3.12.tar.gz
  • Upload date:
  • Size: 22.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/37.3 requests/2.28.1 requests-toolbelt/0.10.1 urllib3/1.26.12 tqdm/4.64.1 importlib-metadata/5.0.0 keyring/23.11.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.9.15

File hashes

Hashes for wipac-rest-tools-1.3.12.tar.gz
Algorithm Hash digest
SHA256 e8adb5e56bdcd4c103e4e6e1c5431556bfd95354db0dbdbbb06e20aa9a29bf5a
MD5 39175627f31655a3df62c47c0b4a0e7f
BLAKE2b-256 1275b7f4a10e02e4c1991c7d1b19e9372fba3bb643eed93b06f7ca14a54d25b8

See more details on using hashes here.

File details

Details for the file wipac_rest_tools-1.3.12-py3-none-any.whl.

File metadata

  • Download URL: wipac_rest_tools-1.3.12-py3-none-any.whl
  • Upload date:
  • Size: 25.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/37.3 requests/2.28.1 requests-toolbelt/0.10.1 urllib3/1.26.12 tqdm/4.64.1 importlib-metadata/5.0.0 keyring/23.11.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.9.15

File hashes

Hashes for wipac_rest_tools-1.3.12-py3-none-any.whl
Algorithm Hash digest
SHA256 191d6f6f06dbff0226169f5cbd23c14fdd16de8d19f6ec842a57f76b38cddb37
MD5 fbc1360884c708769526f97f1f2fccc3
BLAKE2b-256 41a9b924d59ec21f093a6973d618ee8180e3c0a232d8d0ffd6c4c4edfcd45541

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page