Node.js web快速入门 -- KoaHub.js组件koa-static-server
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Node.js web快速入门 -- KoaHub.js组件koa-static-server相关的知识,希望对你有一定的参考价值。
koa-static-server
Static file serving middleware for koa with directory, rewrite and index support
koa-static-server
static file serving middleware for koa with directory, rewrite and index support
Installation
$ npm install koa-static-server
API
var koa =
var app =
app
Options
rootDir
{string} directory that is to be serverrootPath
{string} optional rewrite pathlog
{boolean} request access log to consolemaxage
Browser cache max-age in milliseconds. defaults to 0hidden
Allow transfer of hidden files. defaults to falsegzip
Try to serve the gzipped version of a file automatically whengzip
is supported by a client and if the requested file with.gz
extension exists. defaults to true.
Example
See examples for code examples
// example ‘web‘ directory
// web/index.html
// web/file.txt
var serve =
var app =
// root index support
// GET /
// returns index.html
// GET /file.txt
// returns file.txt
app
// folder support
// GET /web/
// returns /web/index.html
// GET /web/file.txt
// returns /web/file.txt
app
// index support
// GET /
// returns /file.txt
app
// rewrite support
// GET /web/
// returns 404
// GET /admin
// returns /admin/index.html
app
app
console
Support
- Issues - open new issue
- IRC -
pkoretic
on freenode - mail - [email protected]
License
MIT
官网
[http://js.koahub.com]http://js.koahub.com
以上是关于Node.js web快速入门 -- KoaHub.js组件koa-static-server的主要内容,如果未能解决你的问题,请参考以下文章
KoaHub.js -- 基于 Koa.js 平台的 Node.js web 快速开发框架之koahub-skip
KoaHub.js -- 基于 Koa.js 平台的 Node.js web 快速开发框架之koahub
KoaHub.js -- 基于 Koa.js 平台的 Node.js web 快速开发框架之koahub-handlebars
KoaHub.js -- 基于 Koa.js 平台的 Node.js web 快速开发框架之koahub-body-res