非常好用的http静态文件服务器

推荐几个非常好用的http静态文件服务程序,小巧、好用。

miniserve

a CLI tool to serve files and dirs over HTTP
For when you really just want to serve some files over HTTP right now!

miniserve采用rust编写,是一个小型的,独立的跨平台CLI工具,允许您仅获取二进制文件并通过HTTP提供一些文件。 有时这只是一种比正确做事更实用、更快捷的方法。

实例截图:

在局域网内作为团队文件归档工具非常方便。

特性

  • 易于使用
  • 正常工作:开箱即用的正确 MIME 类型处理
  • 单个二进制插入,无需额外的依赖项
  • 使用用户名和密码(以及散列密码)进行身份验证支持
  • 超级快速和高度并行(感谢 Rust 和 Actix)
  • 文件夹下载(动态压缩为 或.tar.gz.zip)
  • 文件上传
  • 目录创建
  • 漂亮的主题(支持浅色和深色主题)
  • 扫描二维码快速访问
  • Shell自动补全
  • 合理和安全的默认值
  • TLS(用于支持的体系结构)
  • 支持像在 GitHub 上一样 README.md 渲染

安装

scoop install miniserve

其它系统的安装请参考文档

使用

❯ miniserve -h
miniserve 0.22.0
Sven-Hendrik Haase <svenstaro@gmail.com>, Boastful Squirrel <boastful.squirrel@gmail.com>
For when you really just want to serve some files over HTTP right now!

USAGE:
    miniserve.exe [OPTIONS] [--] [PATH]

ARGS:
    <PATH>    Which path to serve

OPTIONS:
    -a, --auth <AUTH>                               Set authentication. Currently supported formats: username:password, username:sha256:hash, username:sha512:hash (e.g. joe:123, joe:sha256:a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27ae3)
    -c, --color-scheme <COLOR_SCHEME>               Default color scheme [default: squirrel] [possible values: squirrel, archlinux, zenburn, monokai]
    -d, --color-scheme-dark <COLOR_SCHEME_DARK>     Default color scheme [default: archlinux] [possible values: squirrel, archlinux, zenburn, monokai]
    -D, --dirs-first                                List directories first
    -F, --hide-version-footer                       Hide version footer
    -g, --enable-tar-gz                             Enable gz-compressed tar archive generation
    -h, --help                                      Print help information
    -H, --hidden                                    Show hidden files
        --header <HEADER>                           Set custom header for responses
        --hide-theme-selector                       Hide theme selector
    -i, --interfaces <INTERFACES>                   Interface to listen on
        --index <index_file>                        The name of a directory index file to serve, like "index.html"
    -l, --show-symlink-info                         Visualize symlinks in directory listing
    -m, --media-type <MEDIA_TYPE>                   Specify uploadable media types [possible values: image, audio, video]
    -M, --raw-media-type <MEDIA_TYPE_RAW>           Directly specify the uploadable media type expression
    -o, --overwrite-files                           Enable overriding existing files during file upload
    -p, --port <PORT>                               Port to use [default: 8080]
    -P, --no-symlinks                               Hide symlinks in listing and prevent them from being followed
        --print-completions <shell>                 Generate completion file for a shell [possible values: bash, elvish, fish, powershell, zsh]
        --print-manpage                             Generate man page
    -q, --qrcode                                    Enable QR code display
    -r, --enable-tar                                Enable uncompressed tar archive generation
        --random-route                              Generate a random 6-hexdigit route
        --readme                                    Enable README.md rendering in directories
        --route-prefix <ROUTE_PREFIX>               Use a specific route prefix
        --spa                                       Activate SPA (Single Page Application) mode
    -t, --title <TITLE>                             Shown instead of host in page title and heading
        --tls-cert <TLS_CERT>                       TLS certificate to use
        --tls-key <TLS_KEY>                         TLS private key to use
    -u, --upload-files [<ALLOWED_UPLOAD_DIR>...]    Enable file uploading (and optionally specify for which directory)
    -U, --mkdir                                     Enable creating directories
    -v, --verbose                                   Be verbose, includes emitting access logs
    -V, --version                                   Print version information
    -W, --show-wget-footer                          If enabled, display a wget command to recursively download the current directory
    -z, --enable-zip                                Enable zip archive generation

为powershell生成自动补全文件:

❯ miniserve --print-completions powershell

using namespace System.Management.Automation
using namespace System.Management.Automation.Language

Register-ArgumentCompleter -Native -CommandName 'miniserve' -ScriptBlock {
    param($wordToComplete, $commandAst, $cursorPosition)

    $commandElements = $commandAst.CommandElements
    $command = @(
        'miniserve'
        for ($i = 1; $i -lt $commandElements.Count; $i++) {
            $element = $commandElements[$i]
            if ($element -isnot [StringConstantExpressionAst] -or
                $element.StringConstantType -ne [StringConstantType]::BareWord -or
                $element.Value.StartsWith('-') -or
                $element.Value -eq $wordToComplete) {
                break
        }
        $element.Value
    }) -join ';'

    $completions = @(switch ($command) {
        'miniserve' {
            [CompletionResult]::new('--index', 'index', [CompletionResultType]::ParameterName, 'The name of a directory index file to serve, like "index.html"')
            [CompletionResult]::new('-p', 'p', [CompletionResultType]::ParameterName, 'Port to use')
            [CompletionResult]::new('--port', 'port', [CompletionResultType]::ParameterName, 'Port to use')
            [CompletionResult]::new('-i', 'i', [CompletionResultType]::ParameterName, 'Interface to listen on')
            [CompletionResult]::new('--interfaces', 'interfaces', [CompletionResultType]::ParameterName, 'Interface to listen on')
            [CompletionResult]::new('-a', 'a', [CompletionResultType]::ParameterName, 'Set authentication. Currently supported formats: username:password, username:sha256:hash, username:sha512:hash (e.g. joe:123, joe:sha256:a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27ae3)')
            [CompletionResult]::new('--auth', 'auth', [CompletionResultType]::ParameterName, 'Set authentication. Currently supported formats: username:password, username:sha256:hash, username:sha512:hash (e.g. joe:123, joe:sha256:a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27ae3)')
            [CompletionResult]::new('--route-prefix', 'route-prefix', [CompletionResultType]::ParameterName, 'Use a specific route prefix')
            [CompletionResult]::new('-c', 'c', [CompletionResultType]::ParameterName, 'Default color scheme')
            [CompletionResult]::new('--color-scheme', 'color-scheme', [CompletionResultType]::ParameterName, 'Default color scheme')
            [CompletionResult]::new('-d', 'd', [CompletionResultType]::ParameterName, 'Default color scheme')
            [CompletionResult]::new('--color-scheme-dark', 'color-scheme-dark', [CompletionResultType]::ParameterName, 'Default color scheme')
            [CompletionResult]::new('-u', 'u', [CompletionResultType]::ParameterName, 'Enable file uploading (and optionally specify for which directory)')
            [CompletionResult]::new('--upload-files', 'upload-files', [CompletionResultType]::ParameterName, 'Enable file uploading (and optionally specify for which directory)')
            [CompletionResult]::new('-m', 'm', [CompletionResultType]::ParameterName, 'Specify uploadable media types')
            [CompletionResult]::new('--media-type', 'media-type', [CompletionResultType]::ParameterName, 'Specify uploadable media types')
            [CompletionResult]::new('-M', 'M', [CompletionResultType]::ParameterName, 'Directly specify the uploadable media type expression')
            [CompletionResult]::new('--raw-media-type', 'raw-media-type', [CompletionResultType]::ParameterName, 'Directly specify the uploadable media type expression')
            [CompletionResult]::new('-t', 't', [CompletionResultType]::ParameterName, 'Shown instead of host in page title and heading')
            [CompletionResult]::new('--title', 'title', [CompletionResultType]::ParameterName, 'Shown instead of host in page title and heading')
            [CompletionResult]::new('--header', 'header', [CompletionResultType]::ParameterName, 'Set custom header for responses')
            [CompletionResult]::new('--print-completions', 'print-completions', [CompletionResultType]::ParameterName, 'Generate completion file for a shell')
            [CompletionResult]::new('--tls-cert', 'tls-cert', [CompletionResultType]::ParameterName, 'TLS certificate to use')
            [CompletionResult]::new('--tls-key', 'tls-key', [CompletionResultType]::ParameterName, 'TLS private key to use')
            [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help information')
            [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help information')
            [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version information')
            [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version information')
            [CompletionResult]::new('-v', 'v', [CompletionResultType]::ParameterName, 'Be verbose, includes emitting access logs')
            [CompletionResult]::new('--verbose', 'verbose', [CompletionResultType]::ParameterName, 'Be verbose, includes emitting access logs')
            [CompletionResult]::new('--spa', 'spa', [CompletionResultType]::ParameterName, 'Activate SPA (Single Page Application) mode')
            [CompletionResult]::new('--random-route', 'random-route', [CompletionResultType]::ParameterName, 'Generate a random 6-hexdigit route')
            [CompletionResult]::new('-P', 'P', [CompletionResultType]::ParameterName, 'Hide symlinks in listing and prevent them from being followed')
            [CompletionResult]::new('--no-symlinks', 'no-symlinks', [CompletionResultType]::ParameterName, 'Hide symlinks in listing and prevent them from being followed')
            [CompletionResult]::new('-H', 'H', [CompletionResultType]::ParameterName, 'Show hidden files')
            [CompletionResult]::new('--hidden', 'hidden', [CompletionResultType]::ParameterName, 'Show hidden files')
            [CompletionResult]::new('-q', 'q', [CompletionResultType]::ParameterName, 'Enable QR code display')
            [CompletionResult]::new('--qrcode', 'qrcode', [CompletionResultType]::ParameterName, 'Enable QR code display')
            [CompletionResult]::new('-U', 'U', [CompletionResultType]::ParameterName, 'Enable creating directories')
            [CompletionResult]::new('--mkdir', 'mkdir', [CompletionResultType]::ParameterName, 'Enable creating directories')
            [CompletionResult]::new('-o', 'o', [CompletionResultType]::ParameterName, 'Enable overriding existing files during file upload')
            [CompletionResult]::new('--overwrite-files', 'overwrite-files', [CompletionResultType]::ParameterName, 'Enable overriding existing files during file upload')
            [CompletionResult]::new('-r', 'r', [CompletionResultType]::ParameterName, 'Enable uncompressed tar archive generation')
            [CompletionResult]::new('--enable-tar', 'enable-tar', [CompletionResultType]::ParameterName, 'Enable uncompressed tar archive generation')
            [CompletionResult]::new('-g', 'g', [CompletionResultType]::ParameterName, 'Enable gz-compressed tar archive generation')
            [CompletionResult]::new('--enable-tar-gz', 'enable-tar-gz', [CompletionResultType]::ParameterName, 'Enable gz-compressed tar archive generation')
            [CompletionResult]::new('-z', 'z', [CompletionResultType]::ParameterName, 'Enable zip archive generation')
            [CompletionResult]::new('--enable-zip', 'enable-zip', [CompletionResultType]::ParameterName, 'Enable zip archive generation')
            [CompletionResult]::new('-D', 'D', [CompletionResultType]::ParameterName, 'List directories first')
            [CompletionResult]::new('--dirs-first', 'dirs-first', [CompletionResultType]::ParameterName, 'List directories first')
            [CompletionResult]::new('-l', 'l', [CompletionResultType]::ParameterName, 'Visualize symlinks in directory listing')
            [CompletionResult]::new('--show-symlink-info', 'show-symlink-info', [CompletionResultType]::ParameterName, 'Visualize symlinks in directory listing')
            [CompletionResult]::new('-F', 'F', [CompletionResultType]::ParameterName, 'Hide version footer')
            [CompletionResult]::new('--hide-version-footer', 'hide-version-footer', [CompletionResultType]::ParameterName, 'Hide version footer')
            [CompletionResult]::new('--hide-theme-selector', 'hide-theme-selector', [CompletionResultType]::ParameterName, 'Hide theme selector')
            [CompletionResult]::new('-W', 'W', [CompletionResultType]::ParameterName, 'If enabled, display a wget command to recursively download the current directory')
            [CompletionResult]::new('--show-wget-footer', 'show-wget-footer', [CompletionResultType]::ParameterName, 'If enabled, display a wget command to recursively download the current directory')
            [CompletionResult]::new('--print-manpage', 'print-manpage', [CompletionResultType]::ParameterName, 'Generate man page')
            [CompletionResult]::new('--readme', 'readme', [CompletionResultType]::ParameterName, 'Enable README.md rendering in directories')
            break
        }
    })

    $completions.Where{ $_.CompletionText -like "$wordToComplete*" } |
        Sort-Object -Property ListItemText
}

将上面输出的内容追加到powershell的配置文件中:

miniserve --print-completions powershell >> $profile

serve 一个目录:

miniserve http/

serve 单个文件:

miniserve xxx.iso

设置自定义index替代文件列表:

miniserve --index index.html

详细使用请参考文档

dufs

Dufs is a distinctive utility file server that supports static serving, uploading, searching, accessing control, webdav…

这两个项目的功能几乎一样,界面有所区别,dufs也是rust编写的。

实例截图:

特性

  • 静态文件服务
  • 将文件夹下载为zip文件
  • 上传文件和文件夹(拖放)
  • 搜索文件
  • 部分响应(并行/恢复下载)
  • 路径级访问控制
  • 支持https
  • 支持webdav
  • 易于使用

安装

❯ scoop install dufs       
WARN  Scoop uses 'aria2c' for multi-connection downloads.
WARN  Should it cause issues, run 'scoop config aria2-enabled false' to disable it.
WARN  To disable this warning, run 'scoop config aria2-warning-enabled false'.
Installing 'dufs' (0.31.0) [64bit] from main bucket
Starting download with aria2 ...
Download: Download Results:
Download: gid   |stat|avg speed  |path/URI
Download: ======+====+===========+=======================================================
Download: 983615|OK  |   1.1MiB/s|C:/Users/yp.wang/scoop/cache/dufs#0.31.0#https_github.com_sigoden_dufs_releases_download_v0.31.0_dufs-v0.31.0-x86_64-pc-windows-msvc.zip
Download: Status Legend:
Download: (OK):download completed.
Checking hash of dufs-v0.31.0-x86_64-pc-windows-msvc.zip ... ok.
Extracting dufs-v0.31.0-x86_64-pc-windows-msvc.zip ... done.
Linking ~\scoop\apps\dufs\current => ~\scoop\apps\dufs\0.31.0
Creating shim for 'dufs'.
'dufs' (0.31.0) was installed successfully!

其它系统的安装请参考文档

使用

❯ dufs -h
dufs 0.23.0
sigoden <sigoden@gmail.com>
Dufs is a distinctive utility file server - https://github.com/sigoden/dufs

USAGE:
    dufs.exe [OPTIONS] [--] [path]

ARGS:
    <path>    Specific path to serve [default: .]

OPTIONS:
    -b, --bind <addr>...         Specify bind address
    -p, --port <port>            Specify port to listen on [default: 5000]
        --path-prefix <path>     Specify an path prefix
        --hidden <value>         Hide directories from directory listings, separated by `,`
    -a, --auth <rule>...         Add auth for path
        --auth-method <value>    Select auth method [default: digest] [possible values: basic, digest]
    -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
        --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)
        --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 information
    -V, --version                Print version information

伺服当前目录:

dufs

允许 upload、delete、search等所有操作:

dufs -A

详细使用请参考文档

公众号 | FunIO
微信搜一搜 “funio”,发现更多精彩内容。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
gohttp是一个http文件服务器,因为是用go语言写的,所以加了一个go的抬头。之所以用go是因为发布起来是一个二进制文件,不同的平台都可以用,而且没有依赖问题,且稳定性也很好。    这个软件从很久以前就开始写了,第一次提交实在2015年的2月11号,作为组内存放公共文件的一个小软件。一开始的功能只有像 python -mSimpleHTTPServer 那种简单的功能。但是当我看到gotty这个软件的时候 ,意思到一个简单的软件竟然可以做到如此出色。之后这个http文件服务器就不断的被优化着,保持着简单易用的同时,开始赋予了它最强大的功能。    这个软件有很多的技术,隐藏在了其简易朴实的外表之下。请容我简单的介绍下pjax简称页面ajax技术        在gohttp进行目录却换的时候,你会看到地址栏在变,但是页面却是局部刷新的。各种文件的预览功能        所有常见的代码都可以直接在gohttp下预览,如果你用的是chrome浏览器的话,包括pdf,mp4,mp3都可以直接预览。实时的目录zip打包下载        强大的体现在它是实时的,即使你马上在目录下新增了一个文件,点击目录zip下载的时候,这个文件也会出现在里面。二维码的支持        手机下载往往没有电脑下载这么容易,点点鼠标就可以了。但是有了二维码,手机也只用扫一扫就可以下载了。苹果应用的在线安装        iphone应用安装包的扩展名是ipa,但是你还必须有个额外的plist文件才行。以及生成一个itms-services开头的地址,gohttp直接把这些工作都做了,ipa的解析,plist以及下载页面的自动生成。同普通文件一样,只需要点击右侧的生成二维码,然后用iphone手机扫描下,iphone的应用就安装到了你的手机上。PS:坑爹的苹果,就不能像安卓一样简单一点吗README文件的自动显示像github网站上的项目,readme文件都会作为项目的介绍自动显示出来。gohttp也借鉴了一下。如果目录下有readme文件的话,就会自动预览出来。文件上传简单的文件上传也有着出色的表现,可以看到上传的进度,以及支持拖拽的方式上传文件。为了更方便的结合自动发布的功能,文件上传也有其相应的API,上传的时候也可是指定软件的版本号,存储结构参考了python,pypi官方的模式。还有很多很多其他的特性    http basic auth认证,不同文件不同的icon,gzip支持,目录的整合显示.... 还有很多功能等待着你去发现和有能力的你去补充。    截图  标签:gohttp
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值