Coding Challenge

Practice creating a route in a Python Flask server.

We'll cover the following

Problem statement

Currently our webserver.py is a Flask server that serves up user data on two routes, /user/<userid> and /users.

For this code challenge:

  • Add a Flask route /quantity to the webserver.py file. Use a function called get_quantity() that returns the total number of users in the user list as a JSON string that has a key called quantity and the number of users as its value.

  • Use the len() function to get the quantity of the users list.

Note: When we click “Run” below, the widget will ping the /quantity route of the Flask server. Make the required changes before clicking “Run” or it will give a 404 error.

Get hands-on with 1400+ tech skills courses.