工具与资源gist.github.com
HTTP 静态服务器的一行命令大全
HTTP static server one-liners
2020 — 2021,它一次次回到首页
黑点是上首页(≥ 50 分)的那次投稿,空心点是没冲上去的投稿,点越大分数越高。
导读
这个 Gist 收集了用各种语言和工具一行命令启动 HTTP 静态文件服务器的写法,涵盖 Python、Ruby、PHP、Node、Busybox、netcat 等几十种方案,适合临时分享或测试文件时快速起一个服务器。
为什么经久不衰:无需安装任何东西就能起一个静态服务器是开发中的高频需求,这份清单经过多年验证,至今仍是随手可查的实用参考。
HN 评论精选
推荐 rclone serve http,还能直接服务云存储后端
当然还有 rclone:rclone serve http . 你可以把 . 换成其他云存储后端(s3、Google Drive、Dropbox 等),也可以把 http 换成 sftp、webdav、ftp、dlna,支持 Windows/macOS/Linux。(rclone 作者)
nickcw查看英文原文
There is of course rclone: https://rclone.org/commands/rclone_serve_http/ rclone serve http . You can replace . with any of your other cloud storage backends too (s3, google drive, dropbox, etc), or http with sftp, webdav, ftp, dlna. It works on Windos/macOS/Linux. (Rclone author ;-)
提醒默认绑定 0.0.0.0 可能导致 IPv6 连接问题及解决办法
注意很多命令默认绑定 0.0.0.0,这曾让我踩坑:有时解析到 IPv4 能连上,有时解析到 IPv6 就失败,表现为时好时坏。Python3 可以用 python -m http.server -b :: 同时监听 IPv4 和 IPv6,或用 -b localhost 只监听本地。
kevincox查看英文原文
Note that a lot of these bind to 0.0.0.0 by default. This has caused me surprises in the past as I was failing to connect to a host that is available over IPv6. Sometimes it was even intermittent as I would sometime resolve to the IPv4 and sometimes get the IPv6 and fail. For python3 this is easily remedied. python -m http.server -b :: On most OS configurations this will listen on both IPv4 and IPv6. Or for when you only need local access: python -m http.server -b localhost
推荐专用轻量服务器 thttpd 而非通用运行时
我最喜欢 thttpd,它非常小巧、久经考验,而且就是专门干这个的,大多数 Linux 发行版都有包。即使每台 Ubuntu 服务器上都有 Python,我还是不明白为什么不用更轻量的工具来服务静态文件。
lipanski查看英文原文
My favourite is thttpd [1] which is super tiny, battle-tested and actually meant for the job (and only this job). It's available as a package on most Linux distros. Serving a static folder `/static` on port `3000` as user `static-user` and with cache headers set to 60 seconds would go like this: thttpd -D -h 0.0.0.0 -p 3000 -d /static -u static-user -l - -M 60 Even if you've got Python lying around on every Ubuntu server, I still don't get why you wouldn't use something leaner to serve your static files, as long as it's easy to install/configure. Same goes for most of the runtimes in that list. [1] https://www.acme.com/software/thttpd/
解释 Ruby 一行命令中 -run 选项的原理和易混淆之处
ruby -run -ehttpd . -p8000 这个写法有点不直观:-r 加载的 un.rb 是一堆便捷函数的集合,httpd 就是其中之一。由于 Go 推广了单连字符长参数,很容易把 -run 误认为一个独立选项。
satyanash查看英文原文
The ruby one with the -run option is a bit nonintuitive in how it works. $ ruby -run -ehttpd . -p8000 The -r option requires un.rb[1] which is a file full of convenience functions, such as httpd in this example. Classic Ruby. Given that go has popularized long args with a single hyphen (-name etc), it is easy to mistake -run as an option by itself. [1] https://github.com/ruby/ruby/blob/master/lib/un.rb#L323
历次讨论
同类还值得读
直接在浏览器中启动 Linux 内核
Boot a linux kernel right inside your browser.
Fabrice Bellard 的 JSLinux 页面,用 JavaScript 在浏览器里启动一个 Linux 内核,并提供一个可交互的终端环境。
工具与资源上首页 5 次 · 2011–2025bellard.orgHacker News 未公开功能与行为清单(2018)
A List of Hacker News's Undocumented Features and Behaviors (2018)
数据科学家 Max Woolf 整理的 Hacker News 未公开功能与行为清单,涵盖投票机制、排名算法、账号惩罚等社区运作细节。
工具与资源上首页 5 次 · 2019–2025github.comMapSCII:在终端中用盲文和 ASCII 渲染地图
MapSCII – Braille and ASCII map renderer for the console
MapSCII 是一个在命令行终端里渲染地图的开源工具,用盲文字符和 ASCII 字符把地理数据画成可交互浏览的字符地图。
工具与资源上首页 5 次 · 2017–2025github.com顶尖大学的免费在线课程
Free Online Courses from Top Universities
Open Culture 整理的一份免费在线课程合集,汇集了全球顶尖大学(如 MIT、斯坦福、耶鲁等)向公众开放的网络课程资源,涵盖音频、视频等多种形式。
工具与资源上首页 5 次 · 2010–2022openculture.com淘气字符串:容易引发用户输入问题的字符串清单
Naughty Strings: A list of strings likely to cause issues as user-input data
一个 GitHub 仓库,收录了大量容易让程序出问题的用户输入字符串,如特殊字符、emoji、SQL 注入片段、系统命令等,供开发者用于测试输入处理逻辑。
工具与资源上首页 4 次 · 2015–2020github.com