node.js中http-server的使用

http-server的使用:
1、移动端查看pc端写好的html页面:https://blog.csdn.net/qinguanjian_CSDN/article/details/104300536
2、http-server 帮助文档:

============================================================

-p --port Port to use [8080]
-a Address to use [0.0.0.0]
-d Show directory listings [true]
-i Display autoIndex [true]
-g --gzip Serve gzip files when possible [false]
-b --brotli Serve brotli files when possible [false]
If both brotli and gzip are enabled, brotli takes precedence
-e --ext Default file extension if none supplied [none]
-s --silent Suppress log messages from output
–cors[=headers] Enable CORS via the “Access-Control-Allow-Origin” header
Optionally provide CORS headers list separated by commas
-o [path] Open browser window after starting the server.
Optionally provide a URL path to open the browser window to.
-c Cache time (max-age) in seconds [3600], e.g. -c10 for 10 seconds.
To disable caching, use -c-1.
-t Connections timeout in seconds [120], e.g. -t60 for 1 minute.
To disable timeout, use -t0
-U --utc Use UTC time format in log messages.
–log-ip Enable logging of the client’s IP address

-P --proxy Fallback proxy if the request cannot be resolved. e.g.: http://someurl.com

–username Username for basic authentication [none]
Can also be specified with the env variable NODE_HTTP_SERVER_USERNAME
–password Password for basic authentication [none]
Can also be specified with the env variable NODE_HTTP_SERVER_PASSWORD

-S --ssl Enable https.
-C --cert Path to ssl cert file (default: cert.pem).
-K --key Path to ssl key file (default: key.pem).

-r --robots Respond to /robots.txt [User-agent: *\nDisallow: /]
–no-dotfiles Do not show dotfiles
-h --help Print this list and exit.
-v --version Print the version and exit.

===========================================================

-p --port 使用端口[8080]
-a 要使用的地址[0.0.0.0]
-d 显示目录列表[true]
-i 显示自动索引[true]
-g --gzip 在可能的情况下提供gzip文件[false]
-b——brotli 在可能的情况下提供brotli文件[false] 如果同时启用了brotli和gzip,则brotli优先
-e --ext 默认文件扩展名,如果没有提供[none]
-s --silent 从输出中静默禁止日志消息
–cors[=headers] 通过“Access-Control-Allow-Origin”报头启用cors ,可选地提供用逗号分隔的CORS标头列表
-o [path] 启动服务器后打开浏览器窗口,可选地提供打开浏览器窗口的URL路径。
-c 高速缓存时间(max-age),以秒为单位[3600],例如-c10用于10秒。要禁用缓存,请使用-c-1。
-t 连接超时秒数[120],例如-t60为1分钟。要禁用超时,请使用-t0
-U --utc 在日志消息中使用utc时间格式。
–log-ip 允许记录客户端IP地址
-P --proxy 如果请求不能被解析,回退代理。例如:http://someurl.com。
–username 用于基本身份验证的用户名[none] ,还可以用环境变量NODE_HTTP_SERVER_USERNAME指定
–password 用于基本身份验证的密码[none] ,还可以使用环境变量NODE_HTTP_SERVER_PASSWORD指定
-S --ssl 启用https。
-C --cert 证书文件的证书路径(默认:cert.pem)。
-K --key 密钥文件的密钥路径(默认:key.pem)。
-r --robots 响应/robots.txt [User-agent: *\nDisallow: /]
–no-dotfiles 不显示隐藏文件
-h --help 打印帮助列表并退出。
-v --version 打印版本并退出。

3、停止http-server :
在这里插入图片描述

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值