Recall & Review
beginner
What is Flask in the context of a Raspberry Pi?
Flask is a small and simple web framework for Python that lets you create web servers easily on a Raspberry Pi to handle web requests and show web pages.
Click to reveal answer
beginner
How do you install Flask on a Raspberry Pi?
You open the terminal and run:
pip install flask. This command downloads and installs Flask so you can use it in your Python programs.Click to reveal answer
beginner
What is the purpose of the
@app.route('/') decorator in a Flask app?It tells Flask which web address (URL) should run the function below it. For example,
@app.route('/') means the function runs when someone visits the home page.Click to reveal answer
intermediate
Why do you use
app.run(host='0.0.0.0') on a Raspberry Pi?Using
host='0.0.0.0' makes the Flask server listen on all network addresses, so other devices on the same network can access the web server running on the Raspberry Pi.Click to reveal answer
beginner
What is a simple Flask app example to show 'Hello, Raspberry Pi!' on the home page?
from flask import Flask
app = Flask(__name__)
@app.route('/')
def home():
return 'Hello, Raspberry Pi!'
if __name__ == '__main__':
app.run(host='0.0.0.0')
This code creates a web server that shows the message when you visit the Pi's IP address.Click to reveal answer
What command installs Flask on a Raspberry Pi?
✗ Incorrect
Flask is a Python package installed using pip, so the correct command is
pip install flask.What does
@app.route('/') do in a Flask app?✗ Incorrect
The
@app.route('/') decorator tells Flask which URL path runs the function below it, here the home page.Why use
host='0.0.0.0' in app.run() on Raspberry Pi?✗ Incorrect
Setting
host='0.0.0.0' makes the server listen on all network interfaces, so other devices can connect.Which language is Flask written in?
✗ Incorrect
Flask is a web framework written in Python.
What do you need to do before running a Flask app on Raspberry Pi?
✗ Incorrect
You must install Flask with pip before running Flask apps.
Explain how to create and run a simple Flask web server on a Raspberry Pi.
Think about installation, coding, running, and accessing the server.
You got /5 concepts.
Describe why setting the host to '0.0.0.0' is important when running Flask on Raspberry Pi.
Consider how devices on the same network reach the server.
You got /4 concepts.