我想使用Kitura查看本地主机目录中的文件。我写过:
router.all("/test/*", middleware: StaticFileServer())但这似乎不管用
我要查看我目录中的所有文件。类似于directoryIndex
发布于 2017-09-06 11:57:34
您可以将路径传递到要服务于StaticFileServer的目录,作为path参数,默认情况下它是"public"。
router.all("/test/", middleware: StaticFileServer(path: "MyDirectoryWithStaticFiles"))
然后,您将能够访问该目录中的文件,但不能访问目录本身。例如,您将能够执行GET /test/someFile.html,但不能执行/test/。如果您的目录包含/test/,您将能够获得index.html。
有关使用https://github.com/IBM-Swift/Kitura-Sample的示例,请参见StaticFileHandler。
https://stackoverflow.com/questions/46073993
复制相似问题