- var q = "wiki";
- notmuch = exec( "notmuch search " + q, function( error, stdout, stderr ) {
- res.writeHead( 200, { "Content-Type": "text/plain" } );
- res.end( stdout );
- });
-} ).listen( 8124, "127.0.0.1" );
+ var url = parse( req.url );
+ if ( url.pathname.split( "/" ).splice(-1)[0] === "search" ) {
+ exec( "notmuch search " + url.query, function( error, stdout, stderr ) {
+ res.writeHead( 200, { "Content-Type": "text/plain" } );
+ res.end( stdout );
+ });
+ } else {
+ res.writeHead( 404 );
+ res.end("404");
+ }
+}).listen( 8124, "127.0.0.1" );
+