0
0
Flaskframework~10 mins

URL_for with static 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 generate the URL for a static file named 'style.css'.

Flask
url = url_for([1], filename='style.css')
Drag options to blanks, or click blank then click option'
A'url'
B'file'
C'static'
D'path'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'url' or 'file' instead of 'static' as the endpoint name.
Forgetting to pass the filename argument.
2fill in blank
medium

Complete the code to generate the URL for a static image file named 'logo.png' inside the 'images' folder.

Flask
url = url_for('static', filename=[1])
Drag options to blanks, or click blank then click option'
A'images/logo.png'
B'static/logo.png'
C'logo.png'
D'/images/logo.png'
Attempts:
3 left
💡 Hint
Common Mistakes
Using just 'logo.png' without the folder path.
Including 'static/' in the filename argument.
3fill in blank
hard

Fix the error in the code to correctly generate the URL for 'script.js' in the static folder.

Flask
url = url_for([1], filename='script.js')
Drag options to blanks, or click blank then click option'
A'file'
B'static_files'
C'scripts'
D'static'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong endpoint name like 'static_files' or 'scripts'.
Not using quotes around the endpoint name.
4fill in blank
hard

Fill both blanks to generate the URL for 'main.css' inside the 'css' folder in static files.

Flask
url = url_for([1], filename=[2])
Drag options to blanks, or click blank then click option'
A'static'
B'main.css'
C'css/main.css'
D'static/main.css'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'static/main.css' as filename which is incorrect.
Using wrong endpoint names.
5fill in blank
hard

Fill all three blanks to generate the URL for 'app.js' inside the 'js' folder in static files with a query parameter 'v=2'.

Flask
url = url_for([1], filename=[2], [3])
Drag options to blanks, or click blank then click option'
A'static'
B'js/app.js'
Cv=2
Dversion=2
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'version=2' instead of 'v=2' as query parameter.
Including 'static/' in the filename.