重新设置js的默认根页面
我正在尝试使用node.js restify编写宁静的应用程序。 这是我的应用程序的代码:
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/
但现在我收到了
{"code":"ResourceNotFound","message":"/"}
试试这个:
server.get(/\//, restify.serveStatic({ directory: './content', default: 'index.html' }));