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.
Usage
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
parameter refers tofull.module.path:asgi_object
, and will change according to how you set the file.
License
© 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.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6f42373293926c773539ba3ef0611c59df4db778ad80910280680b01826a547 |
|
MD5 | 2c684ed1faf8925f3abe83ef87ab83a8 |
|
BLAKE2b-256 | a87ebfa72ee82173e7546cc3276299b9db8620bc98d9f51441fa5f7a3d038427 |