Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add server example (using express)

  • Loading branch information...
commit e847bd5cfbdaa0166d1340fef64f0f787e05b00d 1 parent eab415b
Gregoire Lejeune authored
25 tests/server/app.js
View
@@ -0,0 +1,25 @@
+var app = require('express').createServer();
+
+var sys = require('sys'),
+ graphviz = require('graphviz');
+
+app.set('views', __dirname + '/views');
+
+app.get('/', function(req, res){
+ res.render('index.ejs', {});
+});
+
+app.get('/image.png', function(req,res){
+ var g = graphviz.digraph("G");
+ var n1 = g.addNode( "Hello" );
+ n1.set( "color", "red" );
+ n1.set( "style", "filled" );
+ g.addNode( "World" );
+ var e = g.addEdge( n1, "World" );
+ e.set( "color", "red" );
+ g.render( "png", function(render) {
+ res.send(render, { 'Content-Type': 'image/png' })
+ } );
+})
+
+app.listen(3000);
3  tests/server/views/index.ejs
View
@@ -0,0 +1,3 @@
+<p>Hello !</p>
+
+<img src="/image.png" />
5 tests/server/views/layout.ejs
View
@@ -0,0 +1,5 @@
+<html>
+ <body>
+ <%- body %>
+ </body>
+</html>
Please sign in to comment.
Something went wrong with that request. Please try again.