Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gevious/flask_slither
A small library to interface between a mongodb and JSON RESTful API endpoints.
https://github.com/gevious/flask_slither
Last synced: 11 days ago
JSON representation
A small library to interface between a mongodb and JSON RESTful API endpoints.
- Host: GitHub
- URL: https://github.com/gevious/flask_slither
- Owner: gevious
- License: mit
- Created: 2013-05-06T09:23:54.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2019-11-04T00:31:32.000Z (about 5 years ago)
- Last Synced: 2024-09-26T12:48:33.705Z (about 2 months ago)
- Language: Python
- Size: 211 KB
- Stars: 25
- Watchers: 1
- Forks: 1
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
Flask Slither
=============[![Build Status](https://travis-ci.org/gevious/flask_slither.png?branch=master)](https://travis-ci.org/gevious/flask_slither)
[![Build Coverage](https://coveralls.io/repos/gevious/flask_slither/badge.png?branch=master)](https://coveralls.io/r/gevious/flask_slither)A small library to interface between a mongodb and JSON RESTful API resources.
It uses Flask's `MethodView` and populates it with boilerplate code. It is based
on django tastypie.The idea behind Slither
=======================
MongoDB, or any document database, already has JSON payloads in the required
format. Not a lot of work needs to be done in de-normalising the data and
building a JSON payload. Slither aims to be the small layer between the
database and the API resource. It is there to do some housekeeping, but not to
get in the way.The aim is to be fully compatible with the [JSONApi](http://jsonapi.org/) spec as
well as comply to the highest RESTful standards (including HATEOAS) as much as possible.Needed Libraries
================
* Flask
* pymongo
* (optional) MongoKit (when using the mongokit validation)Usage
=====
Here are the basic code snippets you need to use to get up and running:from flask.ext.slither import register_api
from flask.ext.slither.resources import BaseResourceclass UserResource(BaseResource):
def __init__(self, *args, **kwargs):
self.collection = 'users' # The db collection nameregister_api(app, UserAPI)
Defaults
========
By default no authentication, authorization and validation is done on any
requests. These can be added easily by including them from slither or
by writing your own class and using it with your resource.Custom Resources
================
If having basic GET, POST, PATCH, PUT, DELETE endpoints isn't sufficient, you
can add new endpoints in the usual flask way by adding a new definition with
the @route decorator. At this stage, however, you'll also need to add the
plumbing.