一:http-server
npm install --global http-server
使用,在一個目錄下打開 cmd
http-server [path] [options]
[path]
?defaults to?./public
?if the folder exists, and?./
?otherwise.
可以下載文件,但是不能下載文件夾。
二:dufs
Releases · sigoden/dufs
下載 windows 版,然后解壓后有一個?dufs.exe 放到項目根目錄下,執行
http://127.0.0.1:5000/
樣式很漂亮,如果想要下載文件夾得需要配置
用 cmd 執行?dufs.exe --allow-all 就是允許文件夾下載。
Dufs is a distinctive utility file server - https://github.com/sigoden/dufsUsage: dufs [OPTIONS] [serve-path]Arguments:[serve-path] Specific path to serve [default: .]Options:-c, --config <file> Specify configuration file-b, --bind <addrs> Specify bind address or unix socket-p, --port <port> Specify port to listen on [default: 5000]--path-prefix <path> Specify a path prefix--hidden <value> Hide paths from directory listings, e.g. tmp,*.log,*.lock-a, --auth <rules> Add auth roles, e.g. user:pass@/dir1:rw,/dir2-A, --allow-all Allow all operations--allow-upload Allow upload files/folders--allow-delete Allow delete files/folders--allow-search Allow search files/folders--allow-symlink Allow symlink to files/folders outside root directory--allow-archive Allow download folders as archive file--enable-cors Enable CORS, sets `Access-Control-Allow-Origin: *`--render-index Serve index.html when requesting a directory, returns 404 if not found index.html--render-try-index Serve index.html when requesting a directory, returns directory listing if not found index.html--render-spa Serve SPA(Single Page Application)--assets <path> Set the path to the assets directory for overriding the built-in assets--log-format <format> Customize http log format--log-file <file> Specify the file to save logs to, other than stdout/stderr--compress <level> Set zip compress level [default: low] [possible values: none, low, medium, high]--completions <shell> Print shell completion script for <shell> [possible values: bash, elvish, fish, powershell, zsh]--tls-cert <path> Path to an SSL/TLS certificate to serve with HTTPS--tls-key <path> Path to the SSL/TLS certificate's private key-h, --help Print help-V, --version Print version
centos 用 docker 方式安裝 dufs
首先安裝 docker 環境
Alibaba Cloud Linux 3 安裝 docker-CSDN博客
下載dufs鏡像
docker pull sigoden/dufs
部署dufs應用
- 創建部署目錄
mkdir -p /app/dufs/data && cd /app/dufs/
- 設置目錄權限
chmod 777 -R /app/dufs/
編輯部署文件
- 可以直接使用docker-cli方式部署
docker run -v `pwd`:/data -p 5000:5000 --rm sigoden/dufs /data -A
- 編輯docker-compose.yaml部署文件
version: '3'
services:dufs:image: sigoden/dufsports:- '5000:5000'volumes:- /app/dufs/data:/datacommand: /data -Arestart: always
可以設置路徑別名:command: /data -A --path-prefix dufs
啟動鏡像
docker compose up -d
卸載鏡像
docker compose down
現在可以訪問 dufs 了
三:Live Server
vscode 插件,也是不能下載文件夾