There is a style.css
in public
, but I can\'t seem to make the express static option work. I deleted express
and have done npm i
app.use(express.static('public'));
http://expressjs.com/4x/api.html#express.static
Works just fine for me.
app.js
var express = require('express')
, app = express.createServer();
app.use(express.static(__dirname+'/public'));
app.listen(8080, "127.0.0.1");
mkdir public
cd public
touch README
README
test
$ curl http://localhost:8080/README
test
$ npm ls
connect@1.6.1
express@2.4.4
An important detail that I have overlooked on multiple occasions now is that "public" is not in the URL of the static content you are delivering.
Alfred example nails it but it is easy to miss. The location of the README file is not localhost:8080/public/README, but simply localhost:8080/README