I am trying to get my CSS links to work on my localhost. Right now the Index.html will show in plain text on my server. None of the styling included. Tried the express middleware, but it's still not serving the file. I get a 404 for the CSS files. Below is my code:
App.js:
app.set('view engine', 'html');
app.engine('html', hbs.__express);
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(express.static(path.join(__dirname, 'Public')));
Index.html:
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html">
<link rel="stylesheet" type="text/css" media="all" href="/styles.css">
<link rel="stylesheet" type="text/css" media="all" href="/switchery.min.css">
<script type="text/javascript" src="/switchery.min.js"></script>
</head>
//EDIT//
I was setting up the argument for path.join incorrectly. Thanks for all of the answers. Greatly appreciated. Below is the code that worked:
app.use(express.static(path.join(__dirname + '/public')));
app.use(express.static(__dirname + '/Public'));? and of course make sure your styles.css is inside the /Public/ directory.Publicdirectory?