document.write('<link rel="stylesheet" href="http://flowcoder.com/stylesheets/pygment_trac.css" />');
document.write('<link rel="stylesheet" href="http://flowcoder.com/stylesheets/embed.css" />');
document.write('<div class="flowcoder_post flowcoder_clearfix">');
document.write('<div class="flowcoder_posttitle"><a href=\"http://flowcoder.com/100\">Node.JS Image Web Server (using CoffeeScript)<\/a></div>');
document.write('<div class="flowcoder_postbody flowcoder_syntax"><div class=\"highlight\"><pre># NB: this is CoffeeScript!!\n# http://jashkenas.github.com/coffee-script/\n# We assume that you&#39;re storing image files in a &#39;test-images&#39; directory.\n\nsys = require &#39;sys&#39;\nhttp = require &#39;http&#39;\nurl = require &#39;url&#39;\nposix = require &#39;posix&#39;\n\nworkingDir: process.cwd()\n\ngetImageName: (request) -&gt;\n  requestURL = url.parse request.url\n  pathSegs = requestURL.pathname.split &#39;/&#39;\n  pathSegs.shift()\n  pathSegs.shift()\n\nhttp.createServer((request, response) -&gt;\n  imageName: getImageName request\n  headers: { &quot;Content-Type&quot;: &quot;image/jpeg&quot; }\n  imagePath: workingDir + &quot;/test-images/&quot; + imageName\n  posix.cat(imagePath, &quot;binary&quot;).addCallback(\n    (data) -&gt;\n      response.sendHeader 200, headers\n      response.sendBody data, &quot;binary&quot;\n      response.finish()\n  ).addErrback(\n    (err) -&gt;\n      response.sendHeader 404, headers\n      response.finish()\n  )\n).listen 8000\n<\/pre><\/div>\n</div>');
document.write('<div class="flowcoder_bottombar flowcoder_clearfix">');
document.write('<div class="flowcoder_postedby">Posted by <a href=\"http://flowcoder.com/zdzolton\">zdzolton<\/a> on <a href=\"http://flowcoder.com/\">Flowcoder<\/a></div>');
document.write('<div class="flowcoder_viewraw"><a href=\"http://flowcoder.com/100.txt\">view raw<\/a></div>');
document.write('</div></div>');
