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.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 194f3a62884c186af2bd91432ed9d9cb8319a989fdfea0c82609ced4e2aa75a9 |
|
MD5 | 8168aa007fb6fd5aa12dffad906a4ffc |
|
BLAKE2b-256 | 48de17b9a60b4fb16fddd5765951b0c48aa674a792aed656a404821588cd86d8 |