Skip to Content
Building RESTful Python Web Services
book

Building RESTful Python Web Services

by Gastón C. Hillar
October 2016
Intermediate to advanced
418 pages
9h 52m
English
Packt Publishing
Content preview from Building RESTful Python Web Services

Combining blueprints with resourceful routing

Now, we will create the resources that compose our main building blocks for the RESTful API. First, we will create a few instances that we will use in the different resources. Then, we will create a MessageResource class, that we will use to represent the message resource. Create a new views.py file within the api folder and add the following lines. The code file for the sample is included in the restful_python_chapter_06_01 folder, as shown:

from flask import Blueprint, request, jsonify, make_response from flask_restful import Api, Resource from models import db, Category, CategorySchema, Message, MessageSchema from sqlalchemy.exc import SQLAlchemyError import status api_bp = Blueprint('api', __name__) ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Hands-On RESTful Python Web Services - Second Edition

Hands-On RESTful Python Web Services - Second Edition

Gastón C. Hillar

Publisher Resources

ISBN: 9781786462251Supplemental Content