LESSON 2

 

Web frameworks and Flask

 

Lesson 2

Screen 1 of 11

Course progress review

This is lesson 2 of 8

 

1) Components of a Web application

2) Web frameworks and Flask

3) Installing Python and packages

4) Creating your development environment

5) Building your first local Flask app

6) Running your first Flask app

7) Web application deployment

8) Deploying to PythonAnywhere

Lesson 2

Screen 2 of 11

Lesson 2 outcomes

This lesson prepares you to:

 

  • recall a definition of Web frameworks
  • identify how Developers benefit from using Web frameworks
  • recognise features of a Web framework

Lesson 2

Screen 3 of 11

What is a Web framework?

Web applications interact with various components, including client Web browsers, Web servers, remote hosts, file-systems and databases, etc.  Integrating these different components can be challenging for Developers.

 

A Web framework provides Developers with a set of pre-packaged tools and technologies needed to integrate the components of a Web application.

Lesson 2

Screen 4 of 11

Without Web frameworks, Developers would spend a lot of time writing code to integrate the different parts of a Web application.  Web frameworks help Developers focus on writing code to implement a Web application’s features, which enables them to work quickly and efficiently (Reitz and Schlusser 2016).    

 

Web frameworks are also called ‘Web application frameworks’ or ‘frameworks’.

There are many Web frameworks.  The Web application’s requirements determine which particular Web framework is suitable for use.  Most Web frameworks include the following basic features (Reitz and Schlusser 2016, p.201):

  • URL Routing – HTTP requests, coming into a Web application, are mapped or 'routed to particular piece of computer code’ within the Web application.  The Web application runs the code to generate the required output.  
  • Request and Response Objects – are entities used within the Web application’s code to ‘encapsulate the information received from or sent to a user’s browser’.

Lesson 2

Screen 5 of 11

Features of a Web framework

  • Template Engine –  allows the Web application to use computer code, inside HTML templates, for generating output, quickly and dynamically.  Templates help Developers keep the code which implements a Web application’s logic, separated from the code used to create content for display in an end-user’s browser.  Your Flask Web application’s logic will be written in Python code.  
  • Development Web Server – a local Web server, with basic features, that allows a Developer to test her Web application as she builds it.

What is Flask?

The Flask micro-framework (or ‘Flask) is a Web framework for the Python computer programming language.  Flask is a ‘micro-framework’ because, by default, Flask includes a minimal set of tools and technologies, to make developing Web applications quick and easy.

Lesson 2

Screen 6 of 11

Flask includes the four features of a Web application, i.e. URL routing, Request and Response Objects, Template Engine (Jinja2) and a Development Server.

Developers can add tools and technologies (called packages, modules and libraries) to extend Flask’s default features.  

An overview of Flask

Watch the video for an overview of Web frameworks and Flask (Tutorials Point 2018a):

Lesson 2

Screen 7 of 11

Web frameworks quiz

Test your knowledge of Web frameworks with the following quiz.

Lesson 2

Screen 8 of 11

Lesson 2 review

You completed Lesson 2 on Web frameworks and Flask successfully.  You now:

 

  • understand what Web frameworks are and how developers benefit from using them
  • know some features of the Flask Web framework

Lesson 2

Screen 9 of 11

Next lesson

In Lesson 3 you apply what you learned about Web applications and Web frameworks, by installing Python to build your first Flask Web application.

 

After you have reviewed the useful resources on the next screen, proceed to Lesson 3.

Lesson 2

Screen 10 of 11

Useful resources

Lesson 2

Screen 11 of 11

The official Flask Website, created by Flask’s developer Armin Ronacher (2018), is an excellent place to begin learning more about the Flask Web framework.

 

Tutorials Point (2018b) provide a free course on Flask Web development with practical tutorials, useful resources and videos.

Made with Slides.com