Book Image

Python API Development Fundamentals

By : Jack Chan, Ray Chung, Jack Huang
Book Image

Python API Development Fundamentals

By: Jack Chan, Ray Chung, Jack Huang

Overview of this book

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.
Table of Contents (12 chapters)

Setting up the Front-end Interface to Work with the Smilecook API

Please download the smilecook-vuejs folder, which contains the frontend website source code, from

  1. Create a new app in the Heroku platform, which is for deploying our frontend web interface:
    Figure 10.26: Creating a new app in the Heroku platform
  2. Once the app is created, we go to the Settings tab and then Config Vars. Here, we are going to set up an environment variable, which will be used to store the backend API URL:
    Figure 10.27: Setting up an environment variable
  3. Set the variable name to be VUE_APP_API_URL, and insert the backend Smilecook API URL here.
  4. Open the smilecook-vuejs project in PyCharm.
  5. In the PyCharm console, type in the following command to log in to the Heroku CLI:
    $ heroku login
  6. Then, initialize git and add the Heroku repository to the git:remote repository:
    $ git init
    $ heroku...