Python Api Development Fundamentals - Jack Chan Oświęcim

Python is a flexible language that can be used for much more than just script development. By knowing the Python RESTful APIs work, you can build a powerful backend for web applications and mobile applications using Python. You'll take your first steps by building a simple API and learning how the …

od 98,10 Najbliżej: 48 km

Liczba ofert: 1

Oferta sklepu

Opis

Python is a flexible language that can be used for much more than just script development. By knowing the Python RESTful APIs work, you can build a powerful backend for web applications and mobile applications using Python. You'll take your first steps by building a simple API and learning how the frontend web interface can communicate with the backend. You'll also learn how to serialize and deserialize objects using the marshmallow library. Then, you'll learn how to authenticate and authorize users using Flask-JWT. You'll also learn how to enhance your APIs by adding useful features, such as email, image upload, searching, and pagination. You'll wrap up the whole book by deploying your APIs to the cloud. By the end of this book, you'll have the confidence and skill to leverage the power of RESTful APIs and Python to build efficient web applications. Spis treści: Preface About the Book About the Authors Learning Objectives Audience Approach Hardware Requirements Software Requirements Conventions Installation and Setup Additional Resources 1. Your First Step Introduction Understanding API RESTful API REST Constraints/Principles HTTP Protocol HTTP Methods and CRUD The JSON Format HTTP Status Codes Commonly used HTTP Status Codes Open API The Flask Web Framework Building a Simple Recipe Management Application Virtual Environment Exercise 1: Building Our First Flask Application Exercise 2: Managing Recipes with Flask Using curl or httpie to Test All the Endpoints Exercise 3: Testing Our API Endpoints with httpie and curl Postman The Postman GUI Sending a GET Request Sending a POST Request Saving a Request Activity 1: Sending Requests to Our APIs Using Postman Exercise 4: Automated Testing Using Postman Activity 2: Implement and Test the delete_recipe Function Summary 2. Starting to Build Our Project Introduction What is Flask-RESTful? Using Flask-RESTful to Develop Our Recipe-Sharing Platform, "Smilecook" Virtual Environment Exercise 5: Creating a Development Project in PyCharm Creating a Recipe Model Exercise 6: Creating the Recipe Model Resourceful Routing Exercise 7: Defining an API Endpoint for the Recipe Model Exercise 8: Defining the Recipe Resource Exercise 9: Publishing and Unpublishing the Recipes Configuring Endpoints Exercise 10: Creating the Main Application File Making HTTP Requests to the Flask API using curl and httpie Exercise 11: Testing the Endpoints Using curl and httpie Exercise 12: Testing the Auto-Incremented Recipe ID Exercise 13: Getting All the Recipes Back Exercise 14: Testing the Recipe Resources Exercise 15: Negative Testing Exercise 16: Modifying the Recipes Exercise 17: Getting Back Specific Recipes with a Certain ID Activity 3: Testing the APIs Using Postman Activity 4: Implementing the Delete Recipe Function Summary 3. Manipulating a Database with SQLAlchemy Introduction Databases Database Management System SQL ORM Exercise 18: Setting Up a Smilecook Database Defining Our Models Exercise 19: Installing Packages and Defining Models Exercise 20: Using Flask-Migrate to Build a Database Upgrade Script Exercise 21: Applying Database Insertion Activity 5: Creating a User and a Recipe Password Hashing Exercise 22: Implement the User Registration Feature and Hash the Users Password Exercise 23: Testing the Application in Postman Activity 6: Upgrading and Downgrading a Database Summary 4. Authentication Services and Security with JWT Introduction JWT Flask-JWT-Extended Exercise 24: Implementing a User Login Function Exercise 25: Testing the User Login Function Exercise 26: Creating the me Endpoint Designing the Methods in the Recipe Model Exercise 27: Implementing Access-Controlled Recipe Management Functions Exercise 28: Testing the Recipe Management Functions Refresh Tokens Exercise 29: Adding a Refresh Token Function Exercise 30: Obtaining a New Access Token Using a Refresh Token The User Logout Mechanism Exercise 31: Implementing the Logout Function Exercise 32: Testing the Logout Function Activity 7: Implementing Access Control on the publish/unpublish Recipe Function Summary 5. Object Serialization with marshmallow Introduction Serialization versus Deserialization marshmallow A Simple Schema Field Validation Customizing Deserialization Methods UserSchema Design Exercise 33: Using marshmallow to Validate the User Data Exercise 34: Testing the User Endpoint before and after Authentication RecipeSchema Design Exercise 35: Implementing RecipeSchema Exercise 36: Testing the Recipe API The PATCH Method Exercise 37: Using the PATCH Method to Update the Recipe Searching for Authors and Unpublished Recipes Using the webargs Package to Parse the Request Arguments Exercise 38: Implementing Access Control on Recipes Exercise 39: Retrieving Recipes from a Specific Author Activity 8: Serializing the recipe Object Using marshmallow Summary 6. Email Confirmation Introduction Mailgun Exercise 40: Get Started with Using Mailgun Exercise 41: Using the Mailgun API to Send Out Emails User Account Activation Workflow Exercise 42: Generating the Account Activation Token Exercise 43: Sending Out the User Account Activation Email Activity 9: Testing the Complete User Registration and Activation Workflow Setting Up Environment Variables Exercise 44: Setting Up Environment Variables in PyCharm HTML Format Email Activity 10: Creating the HTML Format User Account Activation Email Summary 7. Working with Images Introduction Building the User Avatar Function Exercise 45: Adding the avatar_image Attribute to the User Model Flask-Uploads Upload Sets Exercise 46: Implementing the User Avatar Upload Function Exercise 47: Testing the User Avatar Upload Function Using Postman Image Resizing and Compression Introduction to Pillow Exercise 48: Implementing Image Compression in Our Smilecook Application Exercise 49: Testing the Image Compression Function Activity 11: Implementing the Recipe Cover Image Upload Function Activity 12: Testing the Image Upload Function Summary 8. Pagination, Searching, and Ordering Introduction Pagination Paginated APIs Exercise 50: Implementing Pagination on the Published Recipes Retrieval Function Exercise 51: Testing the Pagination Functions Activity 13: Implementing Pagination on the User-Specific Recipe Retrieval API Activity 14: Testing Pagination on the User-Specific Recipe Retrieval API Recipe Searching Exercise 52: Implementing the Search Function Exercise 53: Testing the Search Function Sorting and Ordering Exercise 54: Implementing Sorting and Ordering Exercise 55: Testing the Sorting and Ordering Feature Activity 15: Searching for Recipes with Specific Ingredients Summary 9. Building More Features Introduction Caching Benefit of Caching Flask-Caching Exercise 56: Implementing Caching Functionality Using Flask-Caching Exercise 57: Testing the Caching Function with Postman Clearing the Cache when Data Updates Activity 16: Getting Cache Data after Updating Recipe Details Exercise 58: Implementing Cache-Clearing Functionality Exercise 59: Verifying the Cache-Clearing Function API Rate Limiting HTTP Headers and Response Codes Flask-Limiter Exercise 60: Implementing API Rate-Limiting Functionality Exercise 61: Verifying the Rate-Limit Function Exercise 62: Adding a Whitelist Activity 17: Adding Multiple Rate-Limit Restrictions Summary 10. Deployment Introduction Deployment Comparing SaaS, PaaS, and IaaS The Heroku Platform Configuration Handling in Smilecook Exercise 63: Configuration Handling for the Production and Development Environments Exercise 64: Adding a Staging Configuration Class Heroku Application Exercise 65: Creating a New Application in Heroku Heroku Add-Ons Exercise 66: Installing Heroku Postgres Setting Up Environment Variables for the Heroku App Exercise 67: Setting Up the App Environment Variables Deployment Using Heroku Git What is Git? What is gitignore? What is Procfile? What is Gunicorn? Exercise 68: Setting Up the Git and the Heroku CLI Exercise 69: Checking the Heroku Postgres Tables in pgAdmin Setting Up Variables in Postman Exercise 70: Setting Up Variables in Postman Activity 18: Changing access_token to a Variable in Postman Setting up the Front-end Interface to Work with the Smilecook API Summary Appendix 1: Your First Step Activity 1: Sending Requests to Our APIs Using Postman Activity 2: Implement and Test the delete_recipe Function 2: Starting to Build Our Project Activity 3: Testing the APIs Using Postman Activity 4: Implementing the Delete Recipe Function 3: Manipulating a Database with SQLAlchemy Activity 5: Creating a User and a Recipe Activity 6: Upgrading and Downgrading a Database 4: Authenticated Services and Security with JWTs Activity 7: Implementing Access Control on the publish/unpublish Recipe Function 5: Validating APIs Using marshmallow Activity 8: Serializing the recipe Object Using marshmallow 6: Email Confirmations Activity 9: Testing the Complete User Registration and Activation Workflow Activity 10: Creating the HTML Format User Account Activation Email 7: Working with Images Activity 11: Implementing the Recipe Cover Image Upload Function Activity 12: Testing the Image Upload Function 8: Pagination, Searching, and Ordering Activity 13: Implementing Pagination on the User-Specific Recipe Retrieval API Activity 14: Testing Pagination on the User-Specific Recipe Retrieval API Activity 15: Searching for Recipes with Specific Ingredients 9: Building More Features Activity 16: Getting Cache Data after Updating Recipe Details Activity 17: Adding Multiple Rate-Limit Restrictions 10: Deployment Activity 18: Changing access_token to a Variable in Postman

Specyfikacja

Podstawowe informacje

Autor
  • Jack Chan;Ray Chung;Jack Huang
Rok wydania
  • 2019
Format
  • PDF
  • MOBI
  • EPUB
Ilość stron
  • 372
Wybrane wydawnictwa
  • Packt Publishing