0
0
Flaskframework~10 mins

Application context in Flask - 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 correctly.

Flask
from flask import [1]
app = [1](__name__)
Drag options to blanks, or click blank then click option'
AFlask
BRequest
Crender_template
DBlueprint
Attempts:
3 left
💡 Hint
Common Mistakes
Importing Request instead of Flask
Using lowercase flask instead of Flask
2fill in blank
medium

Complete the code to push the application context manually.

Flask
with app.[1]():
    # code that needs app context
    pass
Drag options to blanks, or click blank then click option'
Arequest_context
Bapp_context
Csession_context
Dcontext
Attempts:
3 left
💡 Hint
Common Mistakes
Using request_context instead of app_context
Forgetting to use the context manager 'with'
3fill in blank
hard

Fix the error in accessing the current app inside a function.

Flask
from flask import [1]

def get_name():
    return [1].name
Drag options to blanks, or click blank then click option'
Asession
Bg
Crequest
Dcurrent_app
Attempts:
3 left
💡 Hint
Common Mistakes
Using request or session instead of current_app
Trying to access app directly without context
4fill in blank
hard

Fill both blanks to create and push an application context manually.

Flask
ctx = app.[1]()
ctx.[2]()  # push context
Drag options to blanks, or click blank then click option'
Aapp_context
Bpush
Cpop
Drequest_context
Attempts:
3 left
💡 Hint
Common Mistakes
Using request_context instead of app_context
Calling pop instead of push
5fill in blank
hard

Fill all three blanks to access the app config inside an application context.

Flask
from flask import [1]

with app.[2]():
    secret = [3].config['SECRET_KEY']
Drag options to blanks, or click blank then click option'
Acurrent_app
Bapp_context
Crequest_context
Dsession
Attempts:
3 left
💡 Hint
Common Mistakes
Using request_context instead of app_context
Trying to access app.config directly without context