-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
66 lines (45 loc) · 1.54 KB
/
Copy pathapp.js
File metadata and controls
66 lines (45 loc) · 1.54 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
var http = require('http'),
connect = require('connect'),
harmon=require('harmon'),
httpProxy = require('http-proxy');
var selects = [];
var simpleselect = {};
simpleselect.query = '#content';
simpleselect.func = function (node) {
var text='<div class="ujian-hook"></div>';
text+='<script type="text/javascript">var ujian_config = {num:12,picSize:84,textHeight:45};<\/script>';
text+='<script type="text/javascript" src="http://v1.ujian.cc/code/ujian.js?uid=1581234"><\/script>';
var stm = node.createStream({ "outer" : true });
//variable to hold all the info from the data events
var tag = '';
//collect all the data in the stream
stm.on('data', function(data) {
tag += data;
});
//When the read side of the stream has ended..
stm.on('end', function() {
//Print out the tag you can also parse it or regex if you want
//process.stdout.write('tag: ' + tag + '\n');
//process.stdout.write('end: ' + node.name + '\n');
//Now on the write side of the stream write some data using .end()
//N.B. if end isn't called it will just hang.
stm.end(text);
});
//node.createWriteStream().end('<div>+ Trumpet</div>');
}
selects.push(simpleselect);
//
// Basic Connect App
//
var app = connect();
var proxy = httpProxy.createProxyServer({
target: 'http://goldzhan.com',
headers:{ host: 'goldzhan.com' }
})
app.use(harmon([], selects, true));
app.use(
function (req, res) {
proxy.web(req, res);
}
);
http.createServer(app).listen(8080);