0
0
Flaskframework~10 mins

Flask project structure conventions - 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 Flask and create an app instance.

Flask
from flask import [1]
app = [1](__name__)
Drag options to blanks, or click blank then click option'
AFlask
BApp
CFlaskApp
Dflask
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'flask' instead of 'Flask'.
Trying to create app with a wrong class name.
2fill in blank
medium

Complete the code to define a route for the home page.

Flask
@app.[1]('/')
def home():
    return 'Hello, Flask!'
Drag options to blanks, or click blank then click option'
Apath
Burl
Croute
Dendpoint
Attempts:
3 left
💡 Hint
Common Mistakes
Using '@app.url' or '@app.path' which do not exist.
Missing the decorator entirely.
3fill in blank
hard

Fix the error in the app run command to enable debug mode.

Flask
if __name__ == '__main__':
    app.run(debug=[1])
Drag options to blanks, or click blank then click option'
A'True'
B1
Ctrue
DTrue
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'True' as a string instead of the boolean True.
Using lowercase 'true' which is not valid in Python.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension mapping endpoints to their view function names.

Flask
routes = {endpoint: func[1] for endpoint, func in app.[2].items()}
Drag options to blanks, or click blank then click option'
A.__name__
Bview_functions
C.__doc__
D.__str__
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect attributes that do not exist on app.
Trying to call methods instead of accessing attributes.
5fill in blank
hard

Fill all three blanks to create a Flask blueprint and register it.

Flask
from flask import Blueprint

bp = Blueprint('[1]', __name__, url_prefix='[2]')

app.[3](bp)
Drag options to blanks, or click blank then click option'
Aauth
B/auth
Cregister_blueprint
Droute
Attempts:
3 left
💡 Hint
Common Mistakes
Using '@app.route' instead of 'register_blueprint'.
Missing the slash in the URL prefix.
Using the wrong blueprint name.