Hello Express
var express = require('express');
var app = express();
app.get('/', function (req, res) {
res.send('Hello from Library app');
})
app.listen(3000, function () {
console.log('listening ');
})
sendFile
In the previous example we just displayed some text. Now we are going to add an html file into the views folder and name it index.html.
var express = require('express');
var path = require('path');
var app = express();
app.get('/', function(req, res){
res.sendFile(path.join(__dirname, 'views', 'index.html'));
})
app.listen(3000, function(){
console.log('listening');
})
No comments:
Post a Comment