X-Git-Url: https://git.cworth.org/git?p=nodemuch;a=blobdiff_plain;f=example.js;fp=example.js;h=fb57c915549157c8b4f0d78cc027853600db1526;hp=74e5701bd0c9137dcc33c63ada953e109e397b36;hb=0f2625afe523247a0229511db1dbffba9dd560dc;hpb=260c11af146b497c59b9fa74dc7e29bd664de1eb diff --git a/example.js b/example.js index 74e5701..fb57c91 100644 --- a/example.js +++ b/example.js @@ -3,12 +3,18 @@ var http = require( "http" ), 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 ); }); + } 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");