Flask Restplus Save

Fully featured framework for fast, easy and documented API development with Flask

Project README

============== Flask RestPlus

.. image:: https://secure.travis-ci.org/noirbizarre/flask-restplus.svg?branch=master :target: https://travis-ci.org/noirbizarre/flask-restplus?branch=master :alt: Build status .. image:: https://coveralls.io/repos/noirbizarre/flask-restplus/badge.svg?branch=master :target: https://coveralls.io/r/noirbizarre/flask-restplus?branch=master :alt: Code coverage .. image:: https://readthedocs.org/projects/flask-restplus/badge/?version=latest :target: https://flask-restplus.readthedocs.io/en/latest/ :alt: Documentation status .. image:: https://img.shields.io/pypi/l/flask-restplus.svg :target: https://pypi.org/project/flask-restplus :alt: License .. image:: https://img.shields.io/pypi/pyversions/flask-restplus.svg :target: https://pypi.org/project/flask-restplus :alt: Supported Python versions .. image:: https://badges.gitter.im/Join%20Chat.svg :alt: Join the chat at https://gitter.im/noirbizarre/flask-restplus :target: https://gitter.im/noirbizarre/flask-restplus?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge


This project has been forked to Flask-RESTX <https://github.com/python-restx/flask-restx>_ and will be maintained by by the python-restx <https://github.com/python-restx>_ organization. Flask-RESTPlus should be considered unmaintained.

The community has decided to fork the project due to lack of response from the original author @noirbizarre. We have been discussing this eventuality for almost a year <https://github.com/noirbizarre/flask-restplus/issues/593>_.

Things evolved a bit since that discussion and a few of us have been granted maintainers access to the github project, but only the original author has access rights on the PyPi project. As such, we been unable to make any actual releases. To prevent this project from dying out, we have forked it to continue development and to support our users.

Flask-RESTPlus is an extension for Flask_ that adds support for quickly building REST APIs. Flask-RESTPlus encourages best practices with minimal setup. If you are familiar with Flask, Flask-RESTPlus should be easy to pick up. It provides a coherent collection of decorators and tools to describe your API and expose its documentation properly using Swagger_.


Flask-RestPlus requires Python 2.7 or 3.4+.


You can install Flask-Restplus with pip:

.. code-block:: console

$ pip install flask-restplus

or with easy_install:

.. code-block:: console

$ easy_install flask-restplus

Quick start

With Flask-Restplus, you only import the api instance to route and document your endpoints.

.. code-block:: python

from flask import Flask
from flask_restplus import Api, Resource, fields

app = Flask(__name__)
api = Api(app, version='1.0', title='TodoMVC API',
    description='A simple TodoMVC API',

ns = api.namespace('todos', description='TODO operations')

todo = api.model('Todo', {
    'id': fields.Integer(readOnly=True, description='The task unique identifier'),
    'task': fields.String(required=True, description='The task details')

class TodoDAO(object):
    def __init__(self):
        self.counter = 0
        self.todos = []

    def get(self, id):
        for todo in self.todos:
            if todo['id'] == id:
                return todo
        api.abort(404, "Todo {} doesn't exist".format(id))

    def create(self, data):
        todo = data
        todo['id'] = self.counter = self.counter + 1
        return todo

    def update(self, id, data):
        todo = self.get(id)
        return todo

    def delete(self, id):
        todo = self.get(id)

DAO = TodoDAO()
DAO.create({'task': 'Build an API'})
DAO.create({'task': '?????'})
DAO.create({'task': 'profit!'})

class TodoList(Resource):
    '''Shows a list of all todos, and lets you POST to add new tasks'''
    def get(self):
        '''List all tasks'''
        return DAO.todos

    @ns.marshal_with(todo, code=201)
    def post(self):
        '''Create a new task'''
        return DAO.create(api.payload), 201

@ns.response(404, 'Todo not found')
@ns.param('id', 'The task identifier')
class Todo(Resource):
    '''Show a single todo item and lets you delete them'''
    def get(self, id):
        '''Fetch a given resource'''
        return DAO.get(id)

    @ns.response(204, 'Todo deleted')
    def delete(self, id):
        '''Delete a task given its identifier'''
        return '', 204

    def put(self, id):
        '''Update a task given its identifier'''
        return DAO.update(id, api.payload)

if __name__ == '__main__':


Flask-RESTPlus is brought to you by @noirbizarre. Since early 2019 @SteadBytes, @a-luna, @j5awry, @ziirish volunteered to help @noirbizarre keep the project up and running. Of course everyone is welcome to contribute and we will be happy to review your PR's or answer to your issues.


The documentation is hosted on Read the Docs <http://flask-restplus.readthedocs.io/en/latest/>_

.. _Flask: http://flask.pocoo.org/ .. _Swagger: http://swagger.io/


Want to contribute! That's awesome! Check out CONTRIBUTING.rst! <https://github.com/noirbizarre/flask-restplus/blob/master/CONTRIBUTING.rst>_

Open Source Agenda is not affiliated with "Flask Restplus" Project. README Source: noirbizarre/flask-restplus
Open Issues
Last Commit
1 year ago

Open Source Agenda Badge

Open Source Agenda Rating