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.3.0.tar.gz
(9.2 kB
view details)
File details
Details for the file Flask-RESTy-0.3.0.tar.gz
.
File metadata
- Download URL: Flask-RESTy-0.3.0.tar.gz
- Upload date:
- Size: 9.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e69bb84fdf118ce38f5c216aff69885f8278b7e79f46d4bcd7f5c1d126010c53 |
|
MD5 | 21e56edd7e67c29acaedfe0b568be91c |
|
BLAKE2b-256 | b769165b84180671610127485bdb041f1e471973cd753d76bfb3dff8111329cc |