0
0
Flaskframework~10 mins

Serving JavaScript files 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.

Flask
from flask import [1]
Drag options to blanks, or click blank then click option'
Ajsonify
Brender_template
Crequest
DFlask
Attempts:
3 left
💡 Hint
Common Mistakes
Importing render_template instead of Flask
Using incorrect module name
2fill in blank
medium

Complete the code to create a Flask app instance.

Flask
app = [1](__name__)
Drag options to blanks, or click blank then click option'
AFlask
Brequest
Crender_template
Djsonify
Attempts:
3 left
💡 Hint
Common Mistakes
Calling render_template instead of Flask
Forgetting to pass __name__
3fill in blank
hard

Fix the error in the route decorator to serve JavaScript files.

Flask
@app.route('/static/[1]')
Drag options to blanks, or click blank then click option'
Apath:filename
Bfilename
C<path:filename>
D<filename>
Attempts:
3 left
💡 Hint
Common Mistakes
Using angle brackets incorrectly
Missing 'path:' prefix
4fill in blank
hard

Fill both blanks to send a JavaScript file from the static folder.

Flask
return [1]('static', filename=[2])
Drag options to blanks, or click blank then click option'
Asend_from_directory
Bsend_file
Cfilename
Dfile
Attempts:
3 left
💡 Hint
Common Mistakes
Using send_file without folder path
Passing wrong variable name for filename
5fill in blank
hard

Fill all three blanks to define a route that serves JavaScript files correctly.

Flask
@app.route('/js/[1]')
def serve_js([2]):
    return [3]('static/js', filename=[2])
Drag options to blanks, or click blank then click option'
A<filename>
Bfile
Csend_from_directory
Dsend_file
Attempts:
3 left
💡 Hint
Common Mistakes
Mismatching route and function parameter names
Using send_file without folder path