This lab contains the simplest example of a REST API using a named counter as the resource. There is only one data element which is the counter. The counter is kept in memory in a dictionary so it is not persistent. When the service is restarted the counter restarts at zero. (I told you it was simple!)
This lab is to show you the basics of creating a REST API using Flask. We will recreate this API by hand in the lab starting from scratch.
This lab uses Docker and Visual Studio Code with the Remote Containers extension to provide a consistent repeatable disposable development environment for all of the labs in this course.
You will need the following software installed:
- Docker Desktop
- Visual Studio Code
- Remote Containers extension from the Visual Studio Marketplace
All of these can be installed manually by clicking on the links above or you can use a package manager like Homebrew on Mac of Chocolatey on Windows.
Open Visual Studio Code using the code .
command. VS Code will prompt you to reopen in a container and you should say yes. This will take a while as it builds the Docker image and creates a container from it to develop in.
$ code .
Note that there is a period .
after the code
command. This tells Visual Studio Code to open the editor and load the current folder of files.
Once the environment is loaded you should be placed at a bash
prompt in the /app
folder inside of the development container. This folder is mounted to the current working directory of your repository on your computer. This means that any file you edit while inside of the /app
folder in the container is actually being edited on your computer. You can then commit your changes to git
from either inside or outside of the container.
Copyright (c) 2016, 2025 John Rofrano. All rights reserved.
Licensed under the Apache License. See LICENSE
This repository is part of the New York University (NYU) masters class: CSCI-GA.2820-001 DevOps and Agile Methodologies created and taught by John Rofrano, Adjunct Instructor, NYU Courant Institute, Graduate Division, Computer Science, and NYU Stern School of Business.