Wrapper around Flask aimed at conveniently creating microservices
pip install oneservice==0.1.0
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)(dict, int)
tuple containing
the response data and response status codefrom 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.