nl_tokens: Utility functions .
pl_tokens: function serveStaticFile ( path , res , opts ) { opts = opts || { } ; var fsObject = opts . fs || fs ; var mimeObject = opts . mime || mime ; var headers = opts . headers || { } ; var indexFiles = opts . indexFiles || [ 'index.html' , 'index.htm' , 'home.html' , 'home.htm' ] ; fsObject . stat ( path , function ( err , stats ) { if ( ! err ) { if ( stats . isFile ( ) ) { var mtime = stats . mtime , modifiedSince = headers [ 'if-modified-since' ] ; // Check modification date, if available if ( ! modifiedSince || new Date ( modifiedSince ) < mtime ) { fsObject . readFile ( path , function ( err , data ) { res . headers [ "content-type" ] = mimeObject . lookup ( path ) ; res . headers [ "last-modified" ] = mtime . toUTCString ( ) ; res . send ( data ) ; } ) ; // 304 - Not Modified } else { res . statusCode = 304 ; res . end ( ) ; } // If it's a directory, try to serve one of the index files } else if ( stats . isDirectory ( ) ) { for ( var i = 0 , len = indexFiles . length ; i < len ; i ++ ) { var indexFilePath = path + "/" + indexFiles [ i ] ; try { // This will throw an exception if the file is // not there fsObject . statSync ( indexFilePath ) ; serveStaticFile ( indexFilePath , res , opts ) ; return ; } catch ( e ) { // Ignore if the file is not there; otherwise... if ( e . code !== 'ENOENT' ) { throw e ; } } } <mask> . statusCode = 403 ; res . send ( "Directory listing forbidden" ) ; } // 404 - Not Found } else { res . statusCode = 404 ; res . send ( "Not Found" ) ; } } ) ; }