Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

logiclayer-0.1.2.tar.gz (32.8 kB view hashes)

Uploaded Source

Built Distribution

logiclayer-0.1.2-py3-none-any.whl (33.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page