Build a REST API with Flask
Project description
Flask-RESTly
Quick start
pip install flask-restly
By default flask-restly
uses JSON serializer.
from flask import Flask
from flask_restly import FlaskRestly
from flask_restly.decorator import resource, get, delete
app = Flask(__name__)
rest = FlaskRestly(app)
rest.init_app(app)
@resource(name='employees')
class EmployeesResource:
@get('/<id>')
def get_employee(self, id):
return dict(id=int(id))
@get('/')
def get_employees(self):
return dict(entites=[
dict(id=1),
dict(id=2)
])
@delete('/<id>')
def delete_employee(self, **kwargs):
return
with app.app_context():
EmployeesResource()
if __name__ == "__main__":
app.run(host='127.0.0.1', port=5001, debug=True)
$ python main.py
* Serving Flask app "main" (lazy loading)
* Environment: production
WARNING: Do not use the development server in a production environment.
Use a production WSGI server instead.
* Debug mode: on
* Restarting with stat
* Debugger is active!
* Debugger PIN: 210-167-642
* Running on http://127.0.0.1:5001/ (Press CTRL+C to quit)
Features
- Decorators-based routing
- JSON and Protobuf built-in serialization
- Custom serializer support
- Authorization decorators
- Automatic REST-like response codes
- API versioning
Todo
- HATEOAS
- Compression support
- Caching helpers
- ...and few more :)
Usage
Please see examples for more details.
Docs
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
flask-restly-0.5.0.tar.gz
(8.9 kB
view hashes)
Built Distribution
Close
Hashes for flask_restly-0.5.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | efcb175049e849270e365c96f7e7b9e71353f91ffce8d8ca66c8cf35839bc043 |
|
MD5 | 1a2a5157c2709747b0f18fe7668db2bd |
|
BLAKE2b-256 | 086580f21947c66bd4d517c4874041da60b77a79d72db1239a6360c52f0484b5 |