http-server

npm 安装本地server

插件地址:https://www.npmjs.com/package/http-server

// 安装插件
npm install http-server -g

使用方式

http-server [path] [options]

// 在站点目录下开启命令行输入
http-server

// package.json
"scripts": {
     "start": "http-server -a 0.0.0.0 -p 8000",
 }

// 访问: http://localhost:8080 or http://127.0.0.1:8080 

参数

-p 端口号 (默认 8080)

-a IP 地址 (默认 0.0.0.0)

-d 显示目录列表 (默认 'True')

-i 显示 autoIndex (默认 'True')

-e or --ext 如果没有提供默认的文件扩展名(默认 'html')

-s or --silent 禁止日志信息输出

--cors 启用 CORS via the Access-Control-Allow-Origin header

-o 在开始服务后打开浏览器
-c 为 cache-control max-age header 设置Cache time(秒) , e.g. -c10 for 10 seconds (defaults to '3600'). 禁用 caching, 则使用 -c-1.
-U 或 --utc 使用UTC time 格式化log消息

-P or --proxy Proxies all requests which can't be resolved locally to the given url. e.g.: -P http://someurl.com

-S or --ssl 启用 https

-C or --cert ssl cert 文件路径 (default: cert.pem)

-K or --key Path to ssl key file (default: key.pem).

-r or --robots Provide a /robots.txt (whose content defaults to 'User-agent: *\nDisallow: /')

-h or --help 打印以上列表并退出
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,991评论 19 139
  • 1:简介:命令行服务器。 2:优点:简洁,轻便。3:安装: 4:配置: 标红的位置说明:5:参数说明:-p 端口号...
    麦壳儿UIandFE2阅读 1,980评论 0 0
  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 173,540评论 25 708
  • 在开发中,有时候需要共享本地的静态页面给同事,以前一直用的phpstudy,也算比较方便。 但,仅仅是静态页面的话...
    姚冰coding阅读 6,170评论 0 0
  • 故乡长岭 韩裕平 故乡,故乡,故土之乡。故乡,故乡,故地之乡。故乡,故乡,故人之乡。 我的故乡在长岭,我爱我的故乡...
    秭归秀才9条命儿阅读 455评论 4 4