Last active
August 29, 2015 14:04
-
-
Save mmautner/aa9a5a5f60f707cc4883 to your computer and use it in GitHub Desktop.
demo rest api blurb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask | |
from flask.ext.sa_restful import SaApi | |
from models import Todo | |
app = Flask(__name__) | |
api = SaApi(app, url_prefix='/api/v0.1') | |
# registers GET/POST/DELETE/PUT endpoints at '/api/v0.1/todos' (tablename used for url by default) | |
api.add_resource(Todo) | |
app.run() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sqlalchemy import Column | |
from sqlalchemy import Integer | |
from sqlalchemy import String | |
from sqlalchemy.ext.declarative import declarative_base | |
Base = declarative_base() | |
class Todo(Base): | |
__tablename__ = 'todos' | |
id = Column(Integer, primary_key=True) | |
task = Column(String(255)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment