0
0
Raspberry Piprogramming~10 mins

Flask web server on Raspberry Pi - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the Flask class from the flask module.

Raspberry Pi
from flask import [1]
Drag options to blanks, or click blank then click option'
AWeb
BServer
CApp
DFlask
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect class names like Server or App instead of Flask.
2fill in blank
medium

Complete the code to create a Flask app instance named 'app'.

Raspberry Pi
app = [1](__name__)
Drag options to blanks, or click blank then click option'
AServer
BFlask
CWeb
DApp
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect class names or missing parentheses.
3fill in blank
hard

Fix the error in the route decorator to define the home page route.

Raspberry Pi
@app.route('[1]')
def home():
    return 'Hello, Raspberry Pi!'
Drag options to blanks, or click blank then click option'
A/
B/home
Chome
Dindex
Attempts:
3 left
💡 Hint
Common Mistakes
Using route names without a leading slash or incorrect paths.
4fill in blank
hard

Fill both blanks to run the Flask app on all network interfaces with debug mode on.

Raspberry Pi
if __name__ == '__main__':
    app.run(host=[1], debug=[2])
Drag options to blanks, or click blank then click option'
A'0.0.0.0'
BTrue
CFalse
D'localhost'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'localhost' limits access to the Pi only.
Setting debug to False disables helpful error messages.
5fill in blank
hard

Fill all three blanks to create a route '/status' that returns JSON with a message and status code 200.

Raspberry Pi
@app.route([1])
def status():
    return [2], [3]
Drag options to blanks, or click blank then click option'
A'/status'
B{'message': 'Server is running'}
C200
D'/status/'
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect route paths or returning strings instead of dictionaries.