{ "info": { "author": "Alexis M\u00e9taireau", "author_email": "alexis@notmyidea.org", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Internet :: WWW/HTTP :: Dynamic Content", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "Flask REST\n##########\n\nThis library is a tiny REST toolkit intending to simplify your life when you\nwant to create a REST API for your flask apps.\n\nInstall it\n==========\n\nWell, that's really simple, it's packaged and on PyPI, so::\n\n $ pip install flask-rest\n\nUse it\n======\n\nHandlers\n--------\n\nCreate your classes with specific methods (namely add, get, delete and update),\nregister it with an url, and you're good.\n\n\nHere is a simple example on how to use it::\n\n from flask import Blueprint\n from flask_rest import RESTResource, need_auth\n\n # Subclass a RestResource and configure it\n\n api = Blueprint(\"api\", __name__, url_prefix=\"/api\")\n\n # You can define a authenfier if you want to.\n\n class ProjectHandler(object):\n\n def add(self): #This maps on \"post /\"\n form = ProjectForm(csrf_enabled=False) # just for the example\n if form.validate():\n project = form.save()\n db.session.add(project)\n db.session.commit()\n return 201, project.id\n return 400, form.errors # returns a status code and the data\n\n def get(self, project_id): # maps on GET /\n # do your stuff here\n return 200, project\n\n # you can use the \"need_auth\" decorator to do things for you\n @need_auth(authentifier_callable, \"project\") # injects the \"project\" argument if authorised \n def delete(self, project):\n # do your stuff\n return 200, \"DELETED\"\n\n\nOnce your handlers defined, you just have to register them with the app or the\nblueprint::\n\n project_resource = RESTResource(\n name=\"project\", # name of the var to inject to the methods\n route=\"/projects\", # will be availble at /api/projects/*\n app=api, # the app which should handle this\n actions=[\"add\", \"update\", \"delete\", \"get\"], #authorised actions\n handler=ProjectHandler()) # the handler of the request\n\nIf everything should be protected, you can use the `authentifier` argument::\n\n authentifier=check_project\n\nWhere `check_project` is a callable that returns either the project or False if\nthe acces is not authorized.\n\nSerialisation / Deserialisation\n-------------------------------\n\nWhen you are returning python objects, they can be serialized, which could be\nuseful in most of the cases. The only serialisation format supported so far is\nJSON. \n\nTo serialise *normal* python objects, they should have a `_to_serialize`\nattribute, containing all the names of the attributes to serialize. Here is an\nexample::\n\n\n class Member():\n\n _to_serialize = (\"id\", \"name\", \"email\")\n\n def __init__(self, **kwargs):\n for name, value in kwargs.items():\n setattr(self, name, value)\n\nIf you want to have a look at a real use for this, please head to\nhttps://github.com/spiral-project/ihatemoney/blob/master/budget/api.py", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/ametaireau/flask-rest/", "keywords": "", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "Flask-REST", "package_url": "https://pypi.org/project/Flask-REST/", "platform": "", "project_url": "https://pypi.org/project/Flask-REST/", "project_urls": { "Homepage": "http://github.com/ametaireau/flask-rest/" }, "release_url": "https://pypi.org/project/Flask-REST/1.3/", "requires_dist": null, "requires_python": "", "summary": "A simple REST toolkit for Flask", "version": "1.3" }, "last_serial": 3445564, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "c5075c533d930524621379cbeb4655a3", "sha256": "f00c96698bad5f907b62ca8137400874859faa135411982ffa72ed37174fb129" }, "downloads": -1, "filename": "Flask-REST-1.0.tar.gz", "has_sig": false, "md5_digest": "c5075c533d930524621379cbeb4655a3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5180, "upload_time": "2011-10-17T17:22:38", "url": "https://files.pythonhosted.org/packages/ab/b2/ad3796d32f5939f4f6fb29803baeed32a2cef6d8aaf2b4565b5ba1d8f055/Flask-REST-1.0.tar.gz" } ], "1.1": [ { "comment_text": "", "digests": { "md5": "bd587c3809e93aa36e28e3bde45024d4", "sha256": "6ba6d9600c2f2a5c50797bc14a4472ee3937e42cc55e1f26016681ef0db5e351" }, "downloads": -1, "filename": "Flask-REST-1.1.tar.gz", "has_sig": false, "md5_digest": "bd587c3809e93aa36e28e3bde45024d4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5178, "upload_time": "2011-12-16T11:49:21", "url": "https://files.pythonhosted.org/packages/9f/19/fdca270775166d4985f3f655a217deb053111f61156b5bdc59275f1b8fd0/Flask-REST-1.1.tar.gz" } ], "1.3": [ { "comment_text": "", "digests": { "md5": "3b2edf2a0c57fe4e96c2c31198b3c27a", "sha256": "561fddf8ae39f6581c4c2421476ae38ca1dd089c6a8f36a3ad40ca0405d6318f" }, "downloads": -1, "filename": "Flask-REST-1.3.tar.gz", "has_sig": false, "md5_digest": "3b2edf2a0c57fe4e96c2c31198b3c27a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5297, "upload_time": "2017-12-27T16:06:04", "url": "https://files.pythonhosted.org/packages/73/88/c604c41e4f5350da313948451fdf2d1507c0f43aeb5073302b06ecde2b92/Flask-REST-1.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "3b2edf2a0c57fe4e96c2c31198b3c27a", "sha256": "561fddf8ae39f6581c4c2421476ae38ca1dd089c6a8f36a3ad40ca0405d6318f" }, "downloads": -1, "filename": "Flask-REST-1.3.tar.gz", "has_sig": false, "md5_digest": "3b2edf2a0c57fe4e96c2c31198b3c27a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5297, "upload_time": "2017-12-27T16:06:04", "url": "https://files.pythonhosted.org/packages/73/88/c604c41e4f5350da313948451fdf2d1507c0f43aeb5073302b06ecde2b92/Flask-REST-1.3.tar.gz" } ] }