Couldn't make it work by sending the enterprise.html file using node+express Below is the code in apps.js and in the public/html folder has enterprise.html. Have I done something wrong in this code.
var http = require('http'); //add the http module
var myServer = http.createServer(function(res, res) {
// res.writeHead(200, {"Content-Type" : "text/html"});
// res.write("<b>Hello</b> World");
// res.sendFile(html/tenants.html);
res.sendfile(__dirname + '/html/enterprise.html');
res.end();
}); //create a server
myServer.listen(3000);
app.get('/', function(req, res) {
res.sendfile(__dirname + '/html/enterprise.html');
});
Thanks, J
I think app
is express. Simply try to use
app.get('/', function(req, res) {
res.render(__dirname + '/html/enterprise.html');
});
Hmm, it doesn't look like you've set up your server correctly. Right now you have created a webserver using the http
method that comes packaged with node. If you'd like to use express, you need to instantiate it differently. Try this:
var express = require('express'),
app = express();
app.listen(3000, function() {
console.log('Express server listening on port ' + app.get('port'));
});
And then you can listen for requests using the app
variable.
app.get('/', function( req, res) {});
Documentation: