本地文件夹即时变身 Web 服务器(文件服务器)

一: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/dufs

Usage: 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/

  • 设置目录权限

编辑部署文件

  • 可以直接使用docker-cli方式部署

    docker run -v pwd:/data -p 5000:5000 --rm sigoden/dufs /data -A

  • 编辑docker-compose.yaml部署文件

    version: '3'
    services:
    dufs:
    image: sigoden/dufs
    ports:
    - '5000:5000'
    volumes:
    - /app/dufs/data:/data
    command: /data -A
    restart: always

可以设置路径别名:command: /data -A --path-prefix dufs

启动镜像

复制代码
docker compose up -d

卸载镜像

复制代码
docker compose down

现在可以访问 dufs 了

三:Live Server

vscode 插件,也是不能下载文件夹

相关推荐
漫谈网络30 分钟前
什么是RDMA?—— 一场网络通信的范式革命
运维·服务器·网络
tt666qq1 小时前
linux文件系统学习
linux·运维·学习
杨云龙UP1 小时前
SQL Server数据库事务日志问题的诊断与解法(从膨胀到瘦身)
运维·数据库·sql·sqlserver·serverless
七七七七072 小时前
【Linux系统】进程替换
linux·运维·服务器
ss2733 小时前
手写MyBatis第89弹:动态SQL解析与执行时机深度剖析
java·服务器·windows
霍格沃兹软件测试开发3 小时前
Playwright MCP浏览器自动化详解指南
运维·自动化
前行居士3 小时前
Sub-process /usr/bin/dpkg returned an error code (1)
linux·运维·windows
蒋星熠3 小时前
爬虫与自动化技术深度解析:从数据采集到智能运维的完整实战指南
运维·人工智能·爬虫·python·深度学习·机器学习·自动化
迎風吹頭髮4 小时前
UNIX下C语言编程与实践19-UNIX 三级索引结构:直接索引、一级/二级/三级间接索引的文件存储计算
运维·云计算·unix
数智顾问4 小时前
AI自动化测试:接口测试全流程自动化的实现方法——从需求到落地的全链路实践
运维·人工智能·自动化