Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import the Flask class from the flask package.
Flask
from flask import [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Importing SocketIO instead of Flask
Using lowercase flask instead of Flask
Importing unrelated functions
✗ Incorrect
The Flask class is imported from the flask package to create the 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 SocketIO instead of Flask to create app
Forgetting to pass __name__
Calling a function that is not a class
✗ Incorrect
The Flask app instance is created by calling Flask with the current module name.
3fill in blank
hardFix the error in importing SocketIO from the flask_socketio package.
Flask
from flask_socketio import [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Importing Flask from flask_socketio
Importing unrelated functions
Misspelling SocketIO
✗ Incorrect
SocketIO is imported from flask_socketio to enable real-time communication.
4fill in blank
hardFill both blanks to initialize SocketIO with the Flask app and enable CORS.
Flask
socketio = [1](app, cors_allowed_origins=[2])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using Flask instead of SocketIO to initialize
Setting cors_allowed_origins to None
Forgetting to pass the app instance
✗ Incorrect
SocketIO is initialized with the Flask app and CORS is allowed from all origins using '*'.
5fill in blank
hardFill all three blanks to run the SocketIO server with debug mode enabled on port 5000.
Flask
if __name__ == '__main__': socketio.[1](debug=[2], port=[3])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using start instead of run
Setting debug to False or a string
Using wrong port number
✗ Incorrect
The SocketIO server is started by calling run with debug=True and port=5000.