Files: d456a6cc8589489e558e6164750474ed2cfc961e / test / test-79-npm / express-with-jade / express.js
822 bytesRaw
1 | ; |
2 | |
3 | var http = require('http'); |
4 | var express = require('express'); |
5 | var app = express(); |
6 | app.set('views', 'views'); |
7 | app.set('view engine', 'jade'); |
8 | |
9 | app.get('/', function (req, res) { |
10 | res.render('fixture.jade', { title: 'Hey', message: 'Hello there!' }); |
11 | }); |
12 | |
13 | var server = app.listen(1337, function () { |
14 | var port = server.address().port; |
15 | setTimeout(function () { |
16 | http.get('http://127.0.0.1:' + port.toString() + '/', function (res) { |
17 | var chunks = ''; |
18 | res.on('data', function (chunk) { |
19 | chunks += chunk.toString(); |
20 | }).on('end', function () { |
21 | if (chunks === '<html><head><title>Hey</title></head>' + |
22 | '<body><h1>Hello there!</h1></body></html>') { |
23 | console.log('ok'); |
24 | } |
25 | server.close(); |
26 | }); |
27 | }); |
28 | }, 100); |
29 | }); |
30 |
Built with git-ssb-web