CHAPTER 10Create and Debug a Flask App

Flask is a lightweight Web Server Gateway Interface (WSGI) web application framework. Often referred to as a microframework, Flask is designed to keep the core of the application simple and scalable. Though Flask offers suggestions, the framework does not enforce any dependencies or project layouts. Instead, developers have the ability to add new functionality to their app with extensions provided by the community.

In this project, you learn how to create a Flask app and debug it in Visual Studio Code. Sample code is provided in the Flask-app-complete folder to help expediate the app creation. For a detailed review of how to create and manage a Flask app, visit flask.palletsprojects.com.

Getting Started

The project example in this chapter uses the Flask framework to create a web application that generates Lorem ipsum (see Figure 10.1). Lorem ipsum is a Latin-character placeholder text often used to demonstrate document or user-interface layout without relying on meaningful content. The generator takes two input values:

  • Length of Lorem ipsum to generate
  • Format of generated Lorem ipsum (i.e., word or paragraph)

Thus, entering 3 and word generates three words.

Snapshot of the Lorem ipsum app created in this project

Figure 10.1: The Lorem ipsum app created in this project

The files within the Flask-app-complete folder are necessary for completing the exercises in this project and are used ...

Get Visual Studio Code for Python Programmers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.