首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >restify js默认根页面

restify js默认根页面
EN

Stack Overflow用户
提问于 2014-04-27 02:11:53
回答 1查看 337关注 0票数 2

我正在尝试使用node.js restify编写restful应用程序。下面是我的应用程序代码:

代码语言:javascript
复制
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页面,但现在我在那里看到了

代码语言:javascript
复制
{"code":"ResourceNotFound","message":"/"}
EN

回答 1

Stack Overflow用户

发布于 2014-12-19 06:18:13

试一试:

代码语言:javascript
复制
server.get(/\//, restify.serveStatic({
    directory: './content',
    default: 'index.html'
 }));
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23314755

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档