基于 Koa平台Node.js开发的KoaHub.js的静态服务器重写和索引代码
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了基于 Koa平台Node.js开发的KoaHub.js的静态服务器重写和索引代码相关的知识,希望对你有一定的参考价值。
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
以上是关于基于 Koa平台Node.js开发的KoaHub.js的静态服务器重写和索引代码的主要内容,如果未能解决你的问题,请参考以下文章
基于 Koa平台Node.js开发的KoaHub.js的控制器,模型,帮助方法自动加载
KoaHub.js -- 基于 Koa.js 平台的 Node.js web 快速开发框架之koahub-handlebars
KoaHub平台基于Node.js开发的Koa的skip插件代码详情
基于 Koa平台Node.js开发的KoaHub.js连接打印机的代码