im using nodejs and im trying to serve only html files (without jade, ejs ...).
heres my entry point code (index.js):
var express = require('express'); var bodyParser = require('body-parser'); var app = express(); app.set('port', (process.env.PORT || 5000)); app.use(express.static(__dirname + '/public')); app.use(bodyParser.urlencoded({ extended: true })); app.use(bodyParser.json()); app.use(express.static(__dirname + '/public')); app.get('*', function(req, res){ res.render('index.html'); }); app.listen(app.get('port'), function() { });
This is great when I click on the localhost: 5000 / whatever url, but when I try something like localhost: 5000 / whatever, I get the following message: Error: Cannot find module 'html'
im new for nodejs, but I want all routes to display the index.html file. How can i do this?
Thanks.
source share