0
0
Expressframework~10 mins

Serving from multiple directories in Express - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to serve static files from the 'public' directory using Express.

Express
app.use(express.static('[1]'));
Drag options to blanks, or click blank then click option'
Afiles
Bassets
Cstatic
Dpublic
Attempts:
3 left
💡 Hint
Common Mistakes
Using a directory name that does not exist.
Forgetting to use express.static middleware.
2fill in blank
medium

Complete the code to serve static files from the 'images' directory under the '/img' URL path.

Express
app.use('/img', express.static('[1]'));
Drag options to blanks, or click blank then click option'
Apublic/images
Bimg
Cimages
Dstatic/images
Attempts:
3 left
💡 Hint
Common Mistakes
Including the URL path in the folder name.
Using a wrong folder path.
3fill in blank
hard

Fix the error in the code to serve static files from both 'public' and 'assets' directories.

Express
app.use(express.static('[1]'));
app.use(express.static('assets'));
Drag options to blanks, or click blank then click option'
Apublic
Bassets
Cstatic
Dfiles
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same directory twice.
Trying to serve multiple directories in one call.
4fill in blank
hard

Fill both blanks to serve static files from 'public' at root and 'uploads' at '/files'.

Express
app.use(express.static('[1]'));
app.use('/files', express.static('[2]'));
Drag options to blanks, or click blank then click option'
Apublic
Buploads
Cassets
Dstatic
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing folder names and URL paths.
Using wrong folder names.
5fill in blank
hard

Fill all three blanks to serve 'public' at root, 'images' at '/img', and 'downloads' at '/dl'.

Express
app.use(express.static('[1]'));
app.use('/img', express.static('[2]'));
app.use('/dl', express.static('[3]'));
Drag options to blanks, or click blank then click option'
Apublic
Bimages
Cdownloads
Dassets
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping folder names.
Using incorrect URL paths.