Create a server.js file with below code
var express = require('express'),
app = express(),
http = require('http'),
httpServer = http.createServer(app);
app.use('/',express.static(path.join(__dirname, '/public')));
app.set('view engine', 'ejs'); // send HTML files
app.engine('html', require('ejs').renderFile);
app.get('test',function(req, res){
res.render('hello.html',{ 'id' : 'w8m4r9vdfm' });
});
httpServer.listen(8000,"0.0.0.0",function(){
console.log('http on 8000');
});
Folder structure:
app
server.js
public/hello.html
var express = require('express'),
app = express(),
http = require('http'),
httpServer = http.createServer(app);
app.use('/',express.static(path.join(__dirname, '/public')));
app.set('view engine', 'ejs'); // send HTML files
app.engine('html', require('ejs').renderFile);
app.get('test',function(req, res){
res.render('hello.html',{ 'id' : 'w8m4r9vdfm' });
});
httpServer.listen(8000,"0.0.0.0",function(){
console.log('http on 8000');
});
Folder structure:
app
server.js
public/hello.html
No comments:
Post a Comment