This module will present definitions and major distinctions between Python libraries and frameworks, as well as their respective functions in application development. You will study Flask minimal Python micro framework that is widely used for deploying web applications. Routes, request and response objects, error handling, and decorators are some of the critical development and deployment topics covered in this module. At the end of this module, you will have an API built with Flask and a complete application deployed on the web.
Learning Objective
Understand and differentiate between Python libraries and frameworks.
Basic Features of the Flask Web Frame and comparing it with Django.
Create and run a small Flask application with some routes, and learn how to deliver JSON responses via the server to the client.
Parameterize a Flask application using available builtin mechanisms.
Understand the request and response objects in Flask.
Learn to call external APIs from a Flask application and pass parameters to routes.
Recognize commonly returned HTTP statuses for API services, institutions of error handling in Flask, and implement error responses for API endpoints.
Create and deploy a python web application with 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! You can send a POST request to a server by sending data.
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! This decorator is used to specify a route for a desired path in the argument @app.route.
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! With every client call, Flask provides an object called the Request and a Response object.
4. You can use dynamic routes to create ______ endpoints.
API
RESTful (CORRECT)
Object
Dynamic
Correct! Dynamic routes are applied 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! When this code runs, it results in a successful response with a status code of 200.
MODULE 2 GRADED QUIZ: WEB APP DEPLOYMENT USING FLASK
1. The decorator takes the path as an __________.
True (CORRECT)
False
Correct! It makes sending HTTP requests really easy.
2. Which of the following are examples of data visualizations? Select all that apply.
Output
Route
Object
Argument (CORRECT)
Correct! It is accepting from argument the path as decorator.
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! MIME type denotes the media format the response carries.
6. What does UUID stand for?
Unique Universal Identifier
Universal Unique Identifier (CORRECT)
Unique Unit Identifier
Unit Unique Identifier
Correct! UUID is an abbreviation utilized for the phrase Universally Unique Identifier.
7. Every HTTP response contains a _________-digit code.
One
Two
Three (CORRECT)
Four
Correct! Three-digit code is there in every HTTP response along with the answer that states the status as either an error or success.
8. Flask server automatically returns a ______ OK status when you return from the @app.route method.
300
200 (CORRECT)
599
404
Correct! Error codes form the range from 200 to 299 if that means the request was received successfully and the operation has been successfully completed.
9. Flask is a _______ web framework application that provides users with tools for building web applications.
Heavyweight
Lightweight (CORRECT)
Medium weight
Average weight
Correct! Therefore Flask is very much lightweight since it has far lesser built-in features than other frameworks that would otherwise add complexity and possibly, simplicity.
10. Which of the following provides web application access?
Virtual machine
Downloadable application
Program
Web browser (CORRECT)
Correct! A web application is a program or software that is accessibly used through a web browser and interacts with it.
CONCLUSION – Web App Deployment using Flask
This module would try to introduce you on application development in general using Python libraries and frameworks. Regarding the flask topic, it is more important to employ hands-on experience building and deploying web applications. Some of the covered concepts include routes, request and response objects, error handling, and decorators, as well as familiarization for web application development and deployment using Flask.