1 var http = require( "http" ),
2 parse = require( "url" ).parse,
3 exec = require( "child_process" ).exec;
5 http.createServer( function(req, res) {
6 var url = parse( req.url ),
7 action = url.pathname.split( "/" ).splice(-1)[0];
8 if ( action === "search" ) {
9 exec( "notmuch search " + url.query, function( error, stdout, stderr ) {
10 res.writeHead( 200, { "Content-Type": "text/plain" } );
13 } else if ( action === "show" ) {
14 exec( "notmuch show " + url.query, function( error, stdout, stderr ) {
15 res.writeHead( 200, { "Content-Type": "text/plain" } );
22 }).listen( 8124, "127.0.0.1" );
24 console.log( "Server running at http://127.0.0.1:8124/" );