Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Building Web Applications with Flask

You're reading from   Building Web Applications with Flask Use Python and Flask to build amazing web applications, just the way you want them!

Arrow left icon
Product type Paperback
Published in Jun 2015
Publisher
ISBN-13 9781784396152
Length 160 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Toc

Flask-Restless


Flask-Restless is an extension capable of auto-generating a whole RESTful API for your SQLAlchemy models with support for GET, POST, PUT, and DELETE. Most Web services won't need more than that. Another advantage to using Flask-Restless is the chance to extend the auto-generated methods with authentication validation, custom behavior, and custom queries. This is a must-learn extension!

Let's see how our Web service would look with Flask-Restless. We'll also have to install a new library for this example:

pip install Flask-Restless

And then:

# coding:utf-8

from flask import Flask, url_for
from flask.ext.restless import APIManager
from flask.ext.sqlalchemy import SQLAlchemy

app = Flask(__name__)
app.config['SECRET_KEY'] = 'secret'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/employees.sqlite'

db = SQLAlchemy(app)


class Article(db.Model):
    __tablename__ = 'articles'

    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(100), nullable...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image