forked from aaronpowell/html2jade-website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweb.js
31 lines (25 loc) · 751 Bytes
/
web.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
var express = require('express'),
server = express.createServer(),
pub = __dirname + '/static/',
views = __dirname + '/views',
html2jade;
try {
html2jade = require('html2jade');
} catch (err) {
console.log('Failure to load \'html2jade\' module');
html2jade = require('./node_modules/html2jade/lib/html2jade')
}
server.use(express.bodyParser());
server.use(express.static(pub));
server.set('view engine', 'jade');
server.set('views', views);
server.post('/convert', function (req, res) {
var html = req.body.html;
html2jade.convertHtml(html, {}, function (err, jade) {
res.json({ jade: jade });
});
});
server.get('/', function (req, res) {
res.render('index');
});
server.listen(process.env.PORT || 9999);