Creating resource classes to handle users

We just want to be able to create users and use them to authenticate requests. Thus, we will just focus on creating resource classes with just a few methods. We won't create a complete user management system.

We will create the resource classes that represent the user and the collection of users. First, we will create a UserResource class, which we will use to represent a user resource. Open the views.py file within the service folder and add the following lines after the line that creates the Api instance named service and before the declaration of the NotificationResource class. The code file for the sample is included in the restful_python_2_03_02 folder, in the Flask01/service/views.py file:

Get Hands-On RESTful Python Web Services - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.