2014-04-26 4 views
2

node.js restify를 사용하여 편안한 응용 프로그램을 작성하려고합니다.js 기본 루트 페이지를 복원

var restify = require('restify'); 

var server = restify.createServer(); 

server.get(/.*/, restify.serveStatic({ 
    directory: 'content', 
    default: 'index.html' 
})); 

server.listen(3000, function() { 
    console.log('%s listening at %s', server.name, server.url); 
}); 

그래서, 난 단지 http://localhost:3000/index.html으로 index.html을 액세스 할 수 있습니다 : 여기에 내 응용 프로그램의 코드입니다. 또한, 루트 URL에 http://localhost:3000/을 내 index.html 페이지를 볼 것으로 예상하지만 지금은이 시도해가

{"code":"ResourceNotFound","message":"/"} 
+0

해야'server.get (/. * /'not server.get (/ *'또는 유사점?에 대한 점은 무엇입니까? –

+0

임의의 문자열을 처리하는 정규 표현식입니다. 점은 임의의 기호를 의미하고, 별은 임의의 수의 기호를 의미합니다. – ftkvyn

+0

아, 좋은 기능 -이 도움이됩니까 http://stackoverflow.com/questions/20399648/restify-why-serving-working-directory-is-not-possible? - 디렉토리에 관한 - - 유일한 다른 일은 내가 ca를 n은 –

답변

4

수신 해요 :

server.get(/\//, restify.serveStatic({ 
    directory: './content', 
    default: 'index.html' 
}));