Building a REST API Using Python and Flask
Flask is rapidly growing in popularity due to its ease of use. This course will teach you how to build a REST API using Flask, including how to use all the different HTTP methods, connect Flask to a database, and add authentication to your APIs.
What you'll learn
At the core of developing any REST API with the Flask Microframework is a thorough knowledge of how to use Python and Flask. In this course, Building a REST API using Python and Flask, you will learn the skills you need to create a high-quality REST API using these tools. First, you will learn how to set up your project and get routes with all the different HTTP verbs working. Next, you will explore how to connect all your routes to pull data from a SQL database. Finally, you will discover how to add some basic authentication to your routes using decorators. When you are finished with this course, you will have a foundational understanding of how to build a REST API using Flask that will help you immensely as you create APIs in the future.
Table of contents
- How to Add a Post Route 1m
- Getting the Request Body Sent by a Client 1m
- Sending Post Requests to Our Flask App 2m
- Sanitizing Data Sent in Post Request 2m
- Testing How Well We Sanitize Invalid Request Bodies 2m
- Adding New Books to Our Store Using Post 3m
- Mistake to Be Aware of When Using Post in Flask 3m
- Setting Status Codes and Response Bodies for Post Requests 2m
- Setting Location Headers for Post Requests in Flask 1m
- Handling Invalid Post Requests 3m
- Summary 1m
- Configuring a Flask SQLAlchemy Database 3m
- Defining Tables and Columns in Flask SQLAlchemy 3m
- Creating the Database 2m
- Defining a Data Model with Flask SQLAlchemy 4m
- Updating Our Data Model to Query Our Database 2m
- Updating Our Data Model to Delete Entries from Our Database 1m
- Updating Our Data Model to Update Table Entries 2m
- Updating Our Data Model to Replace Table Entries 2m
- Returning Back JSON from Our Data Model 2m
- Updating Our Flask App to Use Our Book Model 3m
- Verifying the Book Model Integration Was Successful 2m
- Summary 0m
- How to Create JWT Tokens 4m
- Adding Authentication for Our Get Route 3m
- Creating a Database for Users Who Are Allowed API Access 4m
- Creating Users That Are Allowed API Access 4m
- Having Users Login to Get a Token 3m
- Creating Decorators to Add API Authentication 3m
- Adding Authentication for All Our Routes Using Decorators 1m
- Summary 1m
- Next Steps 2m