Chilo is a lightweight, form-meets-function, opinionated (yet highly configurable) api framework.
Project description
Chilo is a lightweight, form-meets-function, opinionated (yet highly configurable) api framework
Chilo
Chilo, short for chilorhinophis (meaning two headed snake), is a lightweight, form-meets-function, opinionated (yet highly configurable) api framework.
Benefits
- No route definitions needed; route based on your directory structure
- Built-in OpenAPI request and response validation
- Ease of use with gunicorn
- Generate OpenAPI spec from code base
- Infinitely customizable with middleware extensions
Philosophy
The Chilo philosophy is to provide a dry, configurable, declarative framework, which encourages Happy Path Programming (HPP).
Happy Path Programming is an idea in which inputs are all validated before operated on. This ensures code follows the happy path without the need for mid-level, nested exceptions and all the nasty exception handling that comes with that. The library uses layers of customizable middleware options to allow a developer to easily dictate what constitutes a valid input, without nested conditionals, try/catch blocks or other coding blocks which distract from the happy path which covers the majority of the source code's intended operation.
Documentation & Examples
Quick Start
0. Install
$ pip install chilo_api
# pipenv install chilo_api
# poetry add chilo_api
1. Create main.py
from chilo_api import Chilo
api = Chilo(
base_path='/',
handlers='api/handlers',
)
2. Create First Handler
{PWD}/api/handlers/__init__.py
def get(request, response):
response.body = {'hello': 'world'}
return response
3. Run your API
python -m chilo_api serve --api=main --reload=true
4. Checkout your API
5. Validate Your Endpoint (optional)
from chilo_api import requirements
@requirements(required_params=['greeting'])
def get(request, response):
response.body = {'hello': request.query_params['greeting']}
return response
6. Checkout your API (again)
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 chilo_api-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bae528a86336b63dfca84a18709500ed352e366b734632f2226d994dd7c20c36 |
|
MD5 | 93fa1f15c47d62177186ddffd2c4195f |
|
BLAKE2b-256 | bb7f95426e7e98220aacd1e3922f28db101e092a5fe2112f39be45e83af3f95e |