express - node.js - can't load my files with express3 -
i using express3 , when i'm trying load html/javascript/css files loads html without css.
i'm using code load files -
express.get('/', function (req, res) { res.sendfile("index.html"); res.sendfile("style.css"); res.sendfile("script.js"); });
so can do?
first, link css , javascript page via tags in header of html
<link rel='stylesheet' href='/path/to/style.css' /> <script src='/path/to/javascript.js'></script>
be sure you're using static middleware in app.use() section, tell express find static files.
app.use(express.static(__dirname + '/public'));
now, express app should serve static css , js files.
node.js express
No comments:
Post a Comment