https://github.com/vitalk/flask-api-stub
Simple Flask API example
https://github.com/vitalk/flask-api-stub
Last synced: about 1 month ago
JSON representation
Simple Flask API example
- Host: GitHub
- URL: https://github.com/vitalk/flask-api-stub
- Owner: vitalk
- Created: 2016-12-09T19:35:20.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-12-09T19:35:36.000Z (over 9 years ago)
- Last Synced: 2025-11-19T17:06:48.607Z (8 months ago)
- Language: Python
- Homepage:
- Size: 6.84 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# A Flask API stub
This is a template project repository used for REST API creation. It contains
the minimal configuration files and folders you will need for quick start from
scratch.
Build on top of the:
- [Flask](http://flask.pocoo.org/)
- [sqlalchemy](http://www.sqlalchemy.org/)
- [sqlalchemy-utils](https://sqlalchemy-utils.readthedocs.io/en/latest/index.html)
- [marshmallow](http://marshmallow.readthedocs.io/en/latest/)
- [Flask-Apify](https://github.com/vitalk/flask-apify)
## Usage
```python
from flask_api_stub.model import Model
from flask_api_stub.schema import Schema
from flask_api_stub.resource import Resource, Collection
from myapp.extensions import db, ma, api
class Album(db.Model, Model):
name = db.Column(db.Text)
description = db.Column(db.Text)
class AlbumSchema(Schema):
class Meta:
model = Album
name = ma.Str()
description = ma.Str()
class AlbumResource(Resource):
model = Album
schema = AlbumSchema
methods = ('get', 'put', 'delete')
class AlbumCollection(Collection):
model = Album
schema = AlbumSchema
methods = ('get', 'post')
AlbumResource.register(api)
AlbumCollection.register(api)
```