Coder Social home page Coder Social logo

static-server's Introduction

使用node搭建静态资源服务器

NPM version npm GitHub stars GitHub forks

安装

npm install yumu-static-server -g

使用

server  # 会在当前目录下启动一个静态资源服务器,默认端口为8080

server -p[port] 3000  # 会在当前目录下启动一个静态资源服务器,端口为3000

server -i[index] index.html  # 设置文件夹在默认加载的文件

server -c[charset] UTF-8  # 设置文件默认加载的字符编码

server -cors  # 开启文件跨域

默认配置(会被命令行参数覆盖)

./config/default.json

{
  "port": 8080, // 服务启动的端口号
  "indexPage": "index.html", // 文件夹下默认加载文件
  "openIndexPage": true, // 是否默认加载文件
  "charset": "UTF-8", // 默认字符编码
  "zipMatch": "^\\.(css|js|html)$" // 默认
}

基本功能

  1. 启动静态资源服务器
  2. 端口可配置
  3. 字符编码可配置
  4. 文件夹下默认加载文件可配置
  5. 是否跨域可配置

TODO

  • 引入handlerbars编译模板
  • 支持文件是否跨域
  • 支持https服务

static-server's People

Contributors

wisestcoder avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.