Skip to main content

Wrapper around Flask aimed at conveniently creating microservices

Project description

OneService

Wrapper around Flask aimed at conveniently creating microservices.

Features and limitations:

  • Microservice creates a server that can call a handler method when / is hit (HTTP method is configurable)
  • The handler method receives the request JSON data and must respond with a (dict, int) tuple containing the response data and response status code

Usage

from oneservice import Microservice

def return_doubled(json_data: dict) -> (dict, int):
    return {"result": int(json_data["a"]) * 2}, 200

m = Microservice(handler=return_doubled)
m.start()

You may then hit the microservice and its health endpoint:

curl http://localhost:5000/health
curl -X POST -H "Content-Type: application/json" --data '{"a": 2}' http://localhost:5000/

See /examples for more code usage samples.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

oneservice-1.0.0.tar.gz (3.0 kB view hashes)

Uploaded Source

Built Distribution

oneservice-1.0.0-py3-none-any.whl (3.3 kB view hashes)

Uploaded Python 3

Supported by

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