From the course: Advanced Python: Practical Database Examples

Unlock the full course today

Join today to access over 24,500 courses taught by industry experts.

Create a webpage with Flask

Create a webpage with Flask

- [Instructor] With our virtual environment set up, let's open up Sublime and start setting up our application. The first step is to set up a simple Flask gap. This version won't link to a database. Instead, it'll contain static content that doesn't change. Later, we'll replace the static content with dynamic links to our database. Let's save this file in our workspace. We'll call it app.py. Then we'll import Flask. We also import render_template, which will help us render our HTML files. Next, we'll initialize our application. We create it with the name of the file and save it in a variable called app. With this app variable, we'll be able to set up all the routes in our application for our website visitors to go to. Like we saw with FastAPI, these routes are the different URL paths in our application we're providing content for. The first route we'll define will be the home route. We'll link it to a function called…

Contents