COURSE 7 – DEVELOPING AI APPLICATIONS WITH PYTHON AND FLASK

Module 2: Web App Deployment using Flask

IBM AI DEVELOPER PROFESSIONAL CERTIFICATE

Complete Coursera Study Guide

Last updated:

INTRODUCTION – Web App Deployment using Flask

In this module, you will learn the definitions and key differences between Python libraries and frameworks used for application development. You will be introduced to Flask, a Python-based micro framework for web application deployment. The module covers essential development and deployment concepts, such as routes, request and response objects, error handling, and decorators. After building an API with Flask, you will also learn how to deploy web applications using Flask.

Learning Objectives

  • Define and differentiate between frameworks and libraries.
  • Describe the key features of the Flask web framework and compare it with Django.
  • Create and run a Flask application with basic routes in place, explain how to return JSON response from the server to clients, and describe various configuration options available in Flask.
  • Explain the Flask request and response objects.
  • Describe how to call an external API in Flask and how to pass parameters to routes in Flask.
  • Describe different HTTP status that API services can return, explain how error handling works in Flask, and how to return errors from your API endpoints.
  • Create and deploy a Python web app using Flask.

MODULE 2 PRACTICE QUIZ: WEB APP DEPLOYMENT USING FLASK

1. Which of the following methods sends HTML form data to the server?

  • HEAD
  • POST (CORRECT)
  • PUT
  • GET

Correct! POST request is used to send data to the server.

2. What is @app.route used for?

  • To define a route (CORRECT)
  • To display an output
  • To create a dictionary 
  • To return the length of an object

Correct! The @app.route decorator is used to define a route. The decorator takes the path as an argument.

3. Which of the following are two objects provided by Flask that are used for each client call? (Select two) 

  • Response  (CORRECT)
  • methods
  • Request  (CORRECT)
  • curl

Correct! Flask provides a Request and a Response object for each client call.

4. You can use dynamic routes to create ______ endpoints.

  • API
  • RESTful (CORRECT)
  • Object
  • Dynamic

Correct! You can use dynamic routes to create RESTful endpoints.

5. When working with a Flask server, what is the code number for a successful response?

  • 404
  • 200 (CORRECT)
  • 500
  • 403

Correct! A successful response with a status code of 200 will be sent back when the given code executes.

MODULE 2 GRADED QUIZ: WEB APP DEPLOYMENT USING FLASK

1. True or false. The Requests library is designed to simplify the process of sending HTTP requests.

  • True (CORRECT)
  • False 

Correct! The Requests library is designed to simplify the process of sending HTTP requests.

2. The decorator takes the path as an __________.

  • Output 
  • Route
  • Object
  • Argument (CORRECT)

Correct! The decorator takes the path as an argument.

3. What is the @app decorator used to create?

  • URL handlers (CORRECT)
  • Objects
  • Python files
  • Config Objects

Correct! Use the @app decorator to create URL handlers.

4. In Flask, what code indicates the success or failure of the request?

  • content_type
  • content_length
  • mime-type
  • status_code (CORRECT)

Correct! The status_code indicates the success or failure of the request.

5. In Flask, which code sets the media type of the response?

  • status_code
  • content_length
  • mime-type (CORRECT)
  • content_type

Correct! The mime-type sets the media type of the response.

6. What does UUID stand for?

  • Unique Universal Identifier
  • Universal Unique Identifier (CORRECT)
  • Unique Unit Identifier 
  • Unit Unique Identifier 

Correct! UUID stands for Universal Unique Identifier.

7. Every HTTP response contains a _________-digit code.

  • One
  • Two
  • Three (CORRECT)
  • Four

Correct! Every HTTP response contains a three-digit code indicating different error and success statuses.

8. Flask server automatically returns a ______ OK status when you return from the @app.route method.

  • 300
  • 200 (CORRECT)
  • 599
  • 404

Correct! Error codes from 200 to 299 indicate the request has been received and the requested operation is successful.

9. Flask is a _______ web framework application that provides users with tools for building web applications.

  • Heavyweight
  • Lightweight (CORRECT)
  • Medium weight
  • Average weight

Correct! Flask is considered lightweight because it comes with fewer features than other frameworks.

10. Which of the following provides web application access?

  • Virtual machine
  • Downloadable application
  • Program
  • Web browser (CORRECT)

Correct! A web application is a software or program accessible through a web browser.

CONCLUSION – Web App Deployment using Flask

In conclusion, this module equips you with a solid understanding of Python libraries and frameworks for application development. By focusing on Flask, you will gain practical experience in building and deploying web applications. The module covers crucial concepts like routes, request and response objects, error handling, and decorators, ensuring you are well-prepared to develop and deploy web apps effectively using Flask.