Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import Flask correctly.
Flask
from flask import [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'flask' instead of 'Flask'.
Importing 'app' instead of 'Flask'.
✗ Incorrect
The Flask class is imported from the flask package to create an app instance.
2fill in blank
mediumComplete the code to create a Flask app instance.
Flask
app = [1](__name__) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'flask' instead of 'Flask'.
Using undefined names like 'App' or 'application'.
✗ Incorrect
The Flask class is called with __name__ to create the app instance.
3fill in blank
hardFix the error in the route decorator syntax.
Flask
@app.route([1]) def home(): return "Hello, Flask!"
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting quotes around the route path.
Using variable names instead of string paths.
✗ Incorrect
The route path must be a string, so it needs quotes around '/'.
4fill in blank
hardFill both blanks to run the Flask app in debug mode on port 5000.
Flask
if __name__ == '__main__': app.run(debug=[1], port=[2])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Setting debug to False during development.
Using wrong port numbers.
✗ Incorrect
Debug mode is enabled with True and default port 5000 is used.
5fill in blank
hardFill all three blanks to create a simple route that returns 'Welcome!' when visiting '/welcome'.
Flask
@app.route([1]) def [2](): return [3]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong route path or missing quotes.
Naming function with invalid names.
Returning without quotes or wrong string.
✗ Incorrect
The route decorator uses the path '/welcome', the function is named welcome, and it returns the string "Welcome!".