Last active
August 29, 2015 14:03
-
-
Save hiiamyes/57e922ebbc01705c2631 to your computer and use it in GitHub Desktop.
template for expressjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var app = express(); | |
app.get('/', function(req, res){ | |
res.send('Hello World'); | |
}); | |
var server = app.listen(3000, function() { | |
console.log('Listening on port %d', server.address().port); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<body> | |
<h1>I'm a real H T M L.</h1> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
router.get('/', function(req, res) { | |
res.render('index', { title: 'Express' }); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.get('/', function(req, res){ | |
var path = require('path'); | |
res.sendfile(path.resolve(__dirname+'/../views/iamhtml.html')); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
router.get('/', function(req, res) { | |
// res.render('index', { title: 'Express' }); | |
res.render('iamhtml', { title: 'Express' }); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
router.get('/', function(req, res) { | |
// res.render('index', { title: 'Express' }); | |
// res.render('iamhtml', { title: 'Express' }); | |
res.render('iamhtml.html', { title: 'Express' }); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment