0
0
Raspberry Piprogramming~5 mins

Flask web server on Raspberry Pi - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
Aapt-get install flask
Bpython flask install
Cnpm install flask
Dpip install flask
What does @app.route('/') do in a Flask app?
ADefines the home page URL route
BStarts the Flask server
CImports Flask module
DStops the Flask server
Why use host='0.0.0.0' in app.run() on Raspberry Pi?
ATo install Flask
BTo allow access from other devices on the network
CTo disable the server
DTo run the server only on localhost
Which language is Flask written in?
APython
BJavaScript
CJava
DC++
What do you need to do before running a Flask app on Raspberry Pi?
AFormat the SD card
BInstall Node.js
CInstall Flask using pip
DInstall Java
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.