Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import the Flask-Compress extension.
Flask
from flask_compress import [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'compress' instead of 'Compress'.
Using 'FlaskCompress' which does not exist.
✗ Incorrect
The correct class to import from flask_compress is Compress.
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 'Compress' or 'FlaskCompress' instead of 'Flask'.
Using a lowercase 'flask' which is a module, not a class.
✗ Incorrect
To create a Flask app, you call the Flask class with __name__.
3fill in blank
hardFix the error in initializing Flask-Compress with the app.
Flask
compress = Compress()
compress.[1](app) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'initialize' or 'start' which are not valid methods.
Using 'setup' which is incorrect here.
✗ Incorrect
The method to initialize the extension with the app is init_app.
4fill in blank
hardFill both blanks to configure Flask-Compress to compress responses larger than 500 bytes.
Flask
app.config['COMPRESS_MIN_SIZE'] = [1] compress = Compress() compress.[2](app)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'start' instead of 'init_app'.
Setting the size to 1000 instead of 500.
✗ Incorrect
Set COMPRESS_MIN_SIZE to 500 and initialize with init_app.
5fill in blank
hardFill all three blanks to create a Flask app, configure Flask-Compress, and initialize it.
Flask
from flask import Flask from flask_compress import [1] app = [2](__name__) app.config['COMPRESS_ALGORITHM'] = '[3]' compress = Compress() compress.init_app(app)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'compress' instead of 'Compress'.
Setting algorithm to 'compress' which is invalid.
✗ Incorrect
Import Compress, create app with Flask, and set compression algorithm to gzip.