Serving up static files

I am trying to serve up the static files but nothing seems to be working. I even followed the examples that were shown through the hints.

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

console.log('hello world');

const absolutePath = __dirname + '/views/index.html';

app.use(express.static(__dirname + '/public/style.css'));

app.get('/', function(req, res){

I’m doing the coding challenge from this one I would appreciate the help, thank you.

According to docs:


and it should work.

That didn’t work. I tried it on Replit and on vs code. What worked was app.use('/public', express.static('/public'));

I just tried and it works. Be sure not to have a /.

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