Web前端   发布时间:2019-10-13  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了http-server大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

http-server是基于node.js的一个简单、零配置的命令行web服务器,可以方便实现跨域资源请求,@H_607_1@

#全局安装:@H_607_1@

npm install http-server -g; 全局安装后就可以通过命令行来启动了@H_607_1@

使用:@H_607_1@

title="http-server" alt="http-server" src="https://cn.js-code.com/res/2019/01-14/23/39f73db0e1e933449346c49dfcccbdca.png" >@H_607_1@@H_607_1@@H_607_1@

#安装为一个node应用@H_607_1@

/http-

使用:@H_607_1@

本地启动http-server:@H_607_1@

node bin/http-http://localhost

可用的选项:@H_607_1@

-p:端口号(默认使用8080)@H_607_1@

-a:address to use(默认使用0.0.0.0)@H_607_1@

-d:Show directory lisTings (defaults to 'True')@H_607_1@

-i:Display autoIndex (defaults to 'True')@H_607_1@

-e 或 --ext:Default file extension if none supplied (defaults to 'html')@H_607_1@

-s 或 --silent:Suppress log @R_944_8798@ges from output@H_607_1@

--cors:Enable CORS via the `Access-Control-Allow-Origin` header@H_607_1@

-o:Open browser window after starTing the server@H_607_1@

-c:Set cache time (in seconds) for cache-control max-age header,e.g. -c10 for 10 seconds (defaults to '3600'). To disable caching,use -c-1.@H_607_1@

-U 或 --utc:Use UTC time format in log @R_944_8798@ges.@H_607_1@

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

-S 或 --ssl:Enable https.@H_607_1@

-C 或 --cert:Path to ssl cert file (default: cert.pem).@H_607_1@

-K 或 --key:Path to ssl key file (default: key.pem).@H_607_1@

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

-h 或 --Help:Print this list and exit.@H_607_1@

大佬总结

以上是大佬教程为你收集整理的http-server全部内容,希望文章能够帮你解决http-server所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: