Permalink
Browse files

Grrrr \t

  • Loading branch information...
1 parent a4da031 commit f7549480b6e9af3516b53332d333b1f2c3220bbf @glejeune committed Oct 5, 2010
Showing with 43 additions and 43 deletions.
  1. +43 −43 tests/server/app.js
View
@@ -43,49 +43,49 @@ app.post('/test', function(req,res){
})
app.get('/draw/*', function(req,res){
- var urlData = url.parse(req.params[0]);
-
- var urlPort = urlData.port;
- if( urlPort == undefined ) {
- urlPort = 80;
- }
- var urlHost = urlData.host;
- var urlPath = urlData.pathname;
-
- var client = http.createClient(urlPort, urlHost);
- var request = client.request('GET', urlPath,
- {'host': urlHost});
- request.end();
- request.on('response', function (response) {
- response.setEncoding('utf8');
- if(response.statusCode == 404 ) {
- res.send('<div class="error"><p><b>'+req.params[0]+'</b> does not exist (404 error)</p></div>');
- } else {
- response.on('data', function (chunk) {
- temp.open('dotGraph', function(err, info) {
- fs.write(info.fd, chunk);
- fs.close(info.fd, function(err) {
- graphviz.parse( info.path, function(graph) {
- graph.render( "png", function(render) {
- img = '<img src="data:image/png;base64,'+render.toString("base64")+'"/>'
- res.send(img)
- }, function(code, out, err) {
- img = '<div class="error"><p><b>Render error (code '+code+')</b></p>';
- img += '<p>STDOUT : '+out+'</p>';
- img += '<p>STDERR : '+err+'</p></div>';
- res.send(img)
- });
- }, function(code, out, err){
- img = '<div class="error"><p><b>Parser error (code '+code+')</b></p>';
- img += '<p>STDERR : '+err+'</p></div>';
- img += '<p>STDOUT : '+out+'</p></div>';
- res.send(img)
- });
- });
- });
- });
- }
- });
+ var urlData = url.parse(req.params[0]);
+
+ var urlPort = urlData.port;
+ if( urlPort == undefined ) {
+ urlPort = 80;
+ }
+ var urlHost = urlData.host;
+ var urlPath = urlData.pathname;
+
+ var client = http.createClient(urlPort, urlHost);
+ var request = client.request('GET', urlPath,
+ {'host': urlHost});
+ request.end();
+ request.on('response', function (response) {
+ response.setEncoding('utf8');
+ if(response.statusCode == 404 ) {
+ res.send('<div class="error"><p><b>'+req.params[0]+'</b> does not exist (404 error)</p></div>');
+ } else {
+ response.on('data', function (chunk) {
+ temp.open('dotGraph', function(err, info) {
+ fs.write(info.fd, chunk);
+ fs.close(info.fd, function(err) {
+ graphviz.parse( info.path, function(graph) {
+ graph.render( "png", function(render) {
+ img = '<img src="data:image/png;base64,'+render.toString("base64")+'"/>'
+ res.send(img)
+ }, function(code, out, err) {
+ img = '<div class="error"><p><b>Render error (code '+code+')</b></p>';
+ img += '<p>STDOUT : '+out+'</p>';
+ img += '<p>STDERR : '+err+'</p></div>';
+ res.send(img)
+ });
+ }, function(code, out, err){
+ img = '<div class="error"><p><b>Parser error (code '+code+')</b></p>';
+ img += '<p>STDERR : '+err+'</p></div>';
+ img += '<p>STDOUT : '+out+'</p></div>';
+ res.send(img)
+ });
+ });
+ });
+ });
+ }
+ });
})
app.listen(3000);

0 comments on commit f754948

Please sign in to comment.