Challenge - 5 Problems
Flask Master on Raspberry Pi
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Flask route response output
What is the output when you visit the root URL '/' of this Flask app running on Raspberry Pi?
Raspberry Pi
from flask import Flask app = Flask(__name__) @app.route('/') def home(): return 'Hello from Raspberry Pi!' if __name__ == '__main__': app.run(host='0.0.0.0', port=5000)
Attempts:
2 left
💡 Hint
Look at the return value of the home() function.
✗ Incorrect
The route '/' returns the string 'Hello from Raspberry Pi!'. Visiting this URL shows that exact text.
🧠 Conceptual
intermediate1:30remaining
Purpose of host='0.0.0.0' in Flask app
Why do we use host='0.0.0.0' when running a Flask app on Raspberry Pi?
Attempts:
2 left
💡 Hint
Think about network accessibility from other devices.
✗ Incorrect
Setting host='0.0.0.0' makes the Flask server listen on all network interfaces, allowing other devices to connect.
🔧 Debug
advanced2:30remaining
Identify the error in this Flask app code
What error will this Flask app code produce when run on Raspberry Pi?
Raspberry Pi
from flask import Flask app = Flask(__name__) @app.route('/hello') def hello(): return 'Hello!' if __name__ == '__main__': app.run(host='0.0.0.0')
Attempts:
2 left
💡 Hint
Check the indentation of the function body.
✗ Incorrect
The function hello() has no indentation for its return statement, causing an IndentationError.
❓ Predict Output
advanced2:00remaining
Flask app with dynamic URL parameter output
What is the output when visiting '/user/Alice' on this Flask app running on Raspberry Pi?
Raspberry Pi
from flask import Flask app = Flask(__name__) @app.route('/user/<name>') def user(name): return f'User: {name}' if __name__ == '__main__': app.run(host='0.0.0.0')
Attempts:
2 left
💡 Hint
Look at how the URL parameter is used in the return string.
✗ Incorrect
The route captures the name from the URL and returns it in the string 'User: {name}'.
📝 Syntax
expert3:00remaining
Identify the syntax error in this Flask app snippet
Which option correctly identifies the syntax error in this Flask app code snippet?
Raspberry Pi
from flask import Flask app = Flask(__name__) @app.route('/data') def data(): return {'value': 42} if __name__ == '__main__': app.run(host='0.0.0.0')
Attempts:
2 left
💡 Hint
Think about what Flask accepts as a return value from route functions.
✗ Incorrect
Returning a plain dictionary causes a TypeError because Flask cannot convert it automatically to a response.