Introduction

Chapter 1


App Overview

By the end of this course, you will have built a RESTful API, using test-driven development. The API itself will follow RESTful design principles, using the basic HTTP verbs: GET, POST, PUT, and DELETE.

Endpoint HTTP Method CRUD Method Result
/users GET READ get all users
/users/:id GET READ get a single user
/users POST CREATE add a user
/users/:id PUT UPDATE update a user
/users/:id DELETE DELETE delete a user

Along with Python and Flask, we'll use Docker to quickly set up our local development environment and simplify deployment. SQLAlchemy will be used to interact with a Postgres database. We'll use Pytest instead of unittest for writing unit and integration tests to test the Flask API. Finally, we'll store the code on a GitLab repository and utilize the CI features in GitLab to run tests before deploying to Heroku.

Before diving in, let's take a minute to go over why some of the above tools are being used.

Flask

Flask and Django are the two most popular Python web frameworks. Django is older and more mature than Flask, but it's also more opinionated. On the other hand, Flask is lighter weight so it doesn't make many decisions for you. You get to decide how you want to implement things. At its core, Flask is simple yet extensible, which is perfect for developing RESTful APIs and microservices.

Docker

Docker is a container platform used to streamline application development and deployment workflows across various environments. It's used to create the infrastructure required -- like installing Linux, configuring system-level dependencies, and running Python -- for the web app within a lightweight container than can be moved from your development machine to the production server quickly and easily.

Pytest

Pytest is a test framework for Python that makes it easy (and fun!) to write, organize, and run tests. When compared to unittest, from the Python standard library, Pytest:

  1. Requires less boilerplate code so your test suites will be more readable.
  2. Supports the plain assert statement, which is far more readable and easier to remember compared to the assertSomething methods -- like assertEquals, assertTrue, and assertContains -- in unittest.
  3. Is updated more frequently since it's not part of the Python standard library.
  4. Simplifies setting up and tearing down test state with its fixture system.

GitLab

GitLab is a web-based solution for managing the full software development lifecycle. Along with source code management, they provide a a number of project management and DevOps-related services, like Kanban boards, package management, logging and monitoring, continuous integration and delivery, secrets management, and container orchestration.

For more, review GitLab's DevOps Tools Landscape.

Heroku

Heroku is a cloud Platform as a Service (PaaS) that provides hosting for web applications. They offer abstracted environments where you don't have to manage the underlying infrastructure, making it easy to manage, deploy, and scale web applications. With just a few clicks you can have your app up and running, ready to receive traffic.




Mark as Completed