Book Image

Flask Blueprints

By : Joel Perras
Book Image

Flask Blueprints

By: Joel Perras

Overview of this book

Table of Contents (14 chapters)

Summary


This chapter began somewhat differently than the previous ones. Our objective was to create a JSON-based API instead of a typical web application that produced HTML and consumed submitted HTML form data.

We first took a bit of a sidestep to explain the existence and usefulness of Werkzeug and then created a basic API with a Flask extension called Flask-RESTful. Next, we made sure that our API could be protected by requiring authentication and explained the subtle but fundamental difference between authentication and authorization.

We then looked at how we could implement validation rules for our API in order to ensure that clients could create valid resources (for example, new users, upload photos, and so on). We implemented several functional and integration-level unit tests using the py.test framework.

We finished off the chapter by implementing the most important feature, photo uploads. We ensured that this feature functioned as expected with a few more test cases and then implemented...