Skip to content
This repository was archived by the owner on Feb 18, 2024. It is now read-only.

Colin-b/layab

Repository files navigation

Layab: Wonderful REST API

pypi version Build status Coverage Code style: black Number of tests Number of downloads

Layab stands for Wonderful in Somali and is also a shortcut for Layabout (aren't we all lazy).

This package provides helper functions on top of Flask-RestPlus to create standardized REST API.

Available features

API

You can create a Flask application and a Flask-RestPlus API using the layab.create_api function.

import layab

application, api = layab.create_api(
    __file__,
    title="My API",
    description="This is the purpose of my API",
)

Monitoring

Importing layab will make sure that every flask request is logged as INFO upon reception and return (even in case an exception occurred).

import layab

You can add monitoring endpoints to your API using layab.add_monitoring_namespace function.

The following endpoints will then be available:

  • /health: Providing Health of your API
  • /changelog: Providing the changelog of your application so that clients can check what's new.
import layab

api = None  # Replace with your Flask-RestPlus API instance

def health_details():
    # Health status, Health details
    return "pass", {}

layab.add_monitoring_namespace(api, health_details)

Should you need to check the status of an external HTTP service or a Redis connection, you can rely on healthpy to retrieve the health status and details.

Note that healthpy also handle the merging of multiple status into one.

Configuration

API and logging configuration should be stored in YAML format.

import layab

# Load logging and service configuration
service_configuration = layab.load('path/to/a/file/in/module/folder')

Note that in case your logging configuration file contains execution of Python code, you will need to provide the yaml.UnsafeLoader loader.

import layab
import yaml

# Load logging and service configuration
service_configuration = layab.load('path/to/a/file/in/module/folder', logging_loader=yaml.UnsafeLoader)

How to install

  1. python 3.6+ must be installed
  2. Use pip to install module:
python -m pip install layab

About

Create wonderful REST API in seconds. Layab is powered by Flask-Restplus

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages