0
0
Flaskframework~10 mins

Defining Celery tasks 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 Celery in a Flask app.

Flask
from celery import [1]
Drag options to blanks, or click blank then click option'
ACelery
BTask
Capp
DFlask
Attempts:
3 left
💡 Hint
Common Mistakes
Importing 'Task' instead of 'Celery'.
Trying to import 'Flask' from celery.
2fill in blank
medium

Complete the code to create a Celery instance with Flask app's config.

Flask
celery = Celery(__name__, broker=[1])
Drag options to blanks, or click blank then click option'
Aconfig['BROKER']
Bapp.broker_url
Capp.config['CELERY_BROKER_URL']
D'redis://localhost:6379/0'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a string literal instead of app config.
Using a wrong config key.
3fill in blank
hard

Fix the error in defining a Celery task decorator.

Flask
@celery.[1]
Drag options to blanks, or click blank then click option'
Atasks
Bexecute
Crun
Dtask
Attempts:
3 left
💡 Hint
Common Mistakes
Using @celery.tasks which does not exist.
Using @celery.run or @celery.execute which are invalid.
4fill in blank
hard

Fill both blanks to define a simple Celery task function.

Flask
@celery.[1]
def [2]():
    return 'Hello from Celery!'
Drag options to blanks, or click blank then click option'
Atask
Bhello_task
Crun_task
Dexecute
Attempts:
3 left
💡 Hint
Common Mistakes
Using invalid decorator names.
Using function names with spaces or invalid characters.
5fill in blank
hard

Fill all three blanks to create a Celery task that adds two numbers.

Flask
@celery.[1]
def [2](a, b):
    return a [3] b
Drag options to blanks, or click blank then click option'
Atask
Badd_numbers
C+
D-
Attempts:
3 left
💡 Hint
Common Mistakes
Using subtraction instead of addition.
Using wrong decorator or function names.