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
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-1.0.0.tar.gz
(3.0 kB
view hashes)
Built Distribution
Close
Hashes for oneservice-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ac9fbb499fd823676bbea75455d1bb94830eb2abfa4f752ca5c1c9dc6aadb8e |
|
MD5 | 2777dbd1f5564a19f49822813c252459 |
|
BLAKE2b-256 | 98ff37340c7223337f7b03d81ed811021a1cf2fe60057a79686231572ec90581 |