Building blocks for REST APIs for Flask
Project description
Building blocks for REST APIs for Flask.
Usage
Create a SQLAlchemy model and a marshmallow schema, then:
from flask.ext.resty import Api, GenericModelView
from .models import Widget
from .schemas import WidgetSchema
class WidgetViewBase(GenericModelView):
model = Widget
schema = WidgetSchema()
class WidgetListView(WidgetViewBase):
def get(self):
return self.list()
def post(self):
return self.create()
class WidgetView(WidgetViewBase):
def get(self, id):
return self.retrieve(id)
def patch(self, id):
return self.update(id, partial=True)
def delete(self, id):
return self.destroy(id)
api = Api(app, '/api')
api.add_resource('/widgets', WidgetListView, WidgetView)
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-RESTy-0.2.0.tar.gz
(8.6 kB
view details)
File details
Details for the file Flask-RESTy-0.2.0.tar.gz
.
File metadata
- Download URL: Flask-RESTy-0.2.0.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5025c9a4a9223c05d80bf6701f4342b5703e4d67538c538636f639c682c91690 |
|
MD5 | 6c076614594ffed8649c55143ee7a334 |
|
BLAKE2b-256 | 7a5585504fc6e58813b8a042d9cad75262036a2cf9d34067ed424bceb1f07652 |