A simple framework to quickly compose and use multiple functionalities as endpoints.
Project description
A simple framework to quickly compose and use multiple functionalities as endpoints.
LogicLayer is built upon FastAPI to provide a simple way to group functionalities into reusable modules.
Getting started
To generate a new instance of LogicLayer, create a python file and execute this snippet:
# example.py
import requests
from logiclayer import LogicLayer
from logiclayer.echo import EchoModule # Example module
echo = EchoModule()
def is_online() -> bool:
res = requests.get("http://clients3.google.com/generate_204")
return (res.status_code == 204) and (res.headers.get("Content-Length") == "0")
layer = LogicLayer()
layer.add_check(is_online)
layer.add_module(echo, prefix="/echo")
The layer
object is an ASGI-compatible application, that can be used with uvicorn/gunicorn to run a server, the same way as you would with a FastAPI instance.
$ pip install uvicorn[standard]
$ uvicorn example:layer
Note the example:layer
is the reference to the layer
variable in the example
module, which points to the ASGI app instance.
© 2022 Datawheel, LLC.
This project is licensed under MIT.
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
Built Distribution
Hashes for logiclayer-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7ae3f5bae63b0e69b2d0f77b6a2bc99a892fe39e248e58b7feffdd25de049b5 |
|
MD5 | adb1cabf3ceefacb5790b539875a720e |
|
BLAKE2b-256 | 3f4050e633e092cb4cca63606e3aee38b02011912778ea321405c47abb857277 |