Lazo Lab Sign up

App 7: Your First Website with Flask / Build a guestbook website

Lesson 1 of 10

Hello, web

Flask is a small Python web framework. A route connects a web address to a Python function, and whatever the function returns is shown in the browser.

Key points

  • pip install flask
  • @app.route("/") maps a URL
  • flask --app app run starts it
from flask import Flask
app = Flask(__name__)

@app.route("/")
def home():
    return "<h1>Hello from my first website!</h1>"

Your turn

Save this as app.py, run flask --app app run, and open http://127.0.0.1:5000

Watch a video on thisOpens YouTube search results for “Hello, web” in a new tab

Quiz · +10 XP

What does @app.route("/") do?

Log in to save progress and earn XP.