Basic Node and Express - Serve Static Assets

Tell us what’s happening:
Describe your issue in detail here.

Your code so far

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36

Challenge: Basic Node and Express - Serve Static Assets

Link to the challenge:

Please Tell us what’s happening in your own words.

Learning to describe problems is hard, but it is an important part of learning how to code.

Also, the more you say, the more we can help!

let express = require('express');
let app = express();

//console.log("Hello World");

app.use(express.static(__dirname + "/public"))
 app.get("/", function(req, res) {
 // res.send('Hello Express');
  res.sendFile ( __dirname + "/views/index.html");
   
})

my code is not working i don’t know what to do i need your help please

You need to specify a mount path for the static directory /public.

Look at the last example in the docs

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.