使用http -server 搭建本地简易文件服务器

安装

npm install http-server -g

使用

1. cd project .

2. hs [pwd] -o, 默认是当前路径 ./

3. 其他选项

-p Port to use (defaults to 8080) (常用)

-a Address to use (defaults to 0.0.0.0) (更换主机,基本不用)

-d Show directory listings (defaults to 'True') (展示目录,基本不用)

-i Display autoIndex (defaults to 'True') (默认打开index.html)

-g or --gzip When enabled (defaults to 'False') it will serve ./public/some-file.js.gz in place of ./public/some-file.js when a gzipped version of the file exists and the request accepts gzip encoding. (压缩文件优先, 基本不用)

-e or --ext Default file extension if none supplied (defaults to 'html') (默认文件后缀)

-s or --silent Suppress log messages from output (控制台打印日志)

--cors Enable CORS via the Access-Control-Allow-Origin header (支持跨域,基本不用)

-o Open browser window after starting the server (打开浏览器)

-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.(缓存时间)

-U or --utc Use UTC time format in log messages. (打印时间的格式)

-S or --ssl Enable https. (打开https)

常用

hs ./afaf -p 9999 -o

-o 要放在最后

posted @   小精灵儿Pawn  Views(911)  Comments(0Edit  收藏  举报
编辑推荐:
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· 展开说说关于C#中ORM框架的用法!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?

如果您觉得此文有帮助,可以打赏点钱给我支付宝。 谢谢 -):

点击右上角即可分享
微信分享提示