No project description provided
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
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
oneservice-0.1.0.tar.gz
(3.0 kB
view hashes)
Built Distribution
Close
Hashes for oneservice-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf2692954b56ef1dcba99250c8e0b4b5452ea5256f07ce208737418d66acfe14 |
|
MD5 | dacd2f2c0238a6aaf139745127a444b3 |
|
BLAKE2b-256 | 4bf9573e1a03ba5d46997cea2b63b9fb79cacca3a40a4cbcb8c8a02b0cba1efa |