javascript - 如何使用 restify 提供静态文件?
问题描述
好的,我见过很多类似的问题,但没有一个能解决我的问题或与实际版本配对。Restify
很长一段时间后,我正在尝试使用Express
.
import restify from "restify";
const server = restify.createServer();
server.listen(8080, () => {
console.log("%s listening at %s", server.name, server.url);
});
server.get(
"/",
restify.plugins.serveStatic({
directory: "./public",
default: "index.html"
})
);
我期望在访问路线时index.html
会显示我的文件。/
但是我的服务器正在寻找 css/css/style.css
而不是public/css/style.css
.
关于如何解决这个问题的任何提示?此外,任何有关如何更好地理解这一点的材料都将不胜感激。
解决方案
推荐阅读
- ios - 如何将数组附加到字典?
- javascript - 警告:道具类型失败:提供给“路由”的道具“组件”无效:道具不是路由中的有效 React 组件
- ios - 即使应用程序在 iOS 中终止,我们还能运行后台任务吗
- python - 我们可以在创建记录器对象时指定用户吗
- sql-server - 如何修复 SQL Server 始终加密错误?
- r - 绘图以可视化 a) 多年来的集群大小 b) 集群之间的移动
- html - 共享驱动器上 Outlook 项目的文件链接
- spring - 使用 http://localhost/test 从浏览器调用 Spring Boot 代码时不起作用
- javascript - 如何防止 Enter 导致 Dojo 网站重新加载
- python - Python中的plt.scatter函数在使用时是否包含所有点?