forked from kwangkim/mathjax-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_client.js
43 lines (38 loc) · 923 Bytes
/
test_client.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
32
33
34
35
36
37
38
39
40
41
42
43
var http=require('http');
var pdata = {
"format": "TeX",
"math": "b + y = \\sqrt{f} = \\sum_n^5 {x}",
"svg":true,
"mml":false,
"png":false,
"speakText": true,
"speakRuleset": "mathspeak",
"speakStyle": "default",
"ex": 6,
"width": 1000000,
"linebreaks": false,
};
var datastring = JSON.stringify(pdata);
var options = {
'hostname': 'localhost',
'port': 8003,
'path': '/',
'method': 'POST',
'headers': {
'Content-Type': 'application/json',
'Content-Length': datastring.length
}
};
var request = http.request(options, function(response){
response.setEncoding('utf-8');
var body = '';
response.on('data', function(data){body += data;});
response.on('end', function(){
console.log(body);
});
});
request.on('error', function(e) {
console.log('problem with request: ' + e.message);
});
request.write(datastring);
request.end();