Much like search, but calling "notmuch show" instead.
exec = require( "child_process" ).exec;
http.createServer( function(req, res) {
exec = require( "child_process" ).exec;
http.createServer( function(req, res) {
- var url = parse( req.url );
- if ( url.pathname.split( "/" ).splice(-1)[0] === "search" ) {
+ var url = parse( req.url ),
+ action = url.pathname.split( "/" ).splice(-1)[0];
+ if ( action === "search" ) {
exec( "notmuch search " + url.query, function( error, stdout, stderr ) {
res.writeHead( 200, { "Content-Type": "text/plain" } );
res.end( stdout );
});
exec( "notmuch search " + url.query, function( error, stdout, stderr ) {
res.writeHead( 200, { "Content-Type": "text/plain" } );
res.end( stdout );
});
+ } else if ( action === "show" ) {
+ exec( "notmuch show " + url.query, function( error, stdout, stderr ) {
+ res.writeHead( 200, { "Content-Type": "text/plain" } );
+ res.end( stdout );
+ });
} else {
res.writeHead( 404 );
res.end("404");
} else {
res.writeHead( 404 );
res.end("404");