foyou-http
零依赖、界面现代的 HTTP 文件服务器。一条命令把任意目录共享到局域网,在浏览器里浏览、预览、上传、下载和管理文件。
- 零依赖:只用 Python 标准库,
pip install秒装,Python 3.9+ 即可运行 - 现代界面:列表 / 网格视图、深色模式、移动端适配、无刷新跳转
- 在线预览:图片、视频、音频、PDF、文本与代码(自动识别 UTF-8 / GBK),键盘 ← → 切换
- 上传:多文件、整个文件夹、拖拽上传(可直接拖到子文件夹上),实时进度、速度、可取消,重名自动改名
- 下载:断点续传(Range)、缓存校验(ETag / 304),文件夹或多选项打包成 zip 流式下载
- 管理:新建文件夹、重命名、删除、批量操作、复制链接、右键菜单、快捷键
- 安全:路径穿越防护、跨站提交拦截、Basic 认证、只读模式、上传大小限制;重命名和删除需显式开启
安装
pip install -U foyou-http
# 或使用 pipx 安装为独立命令
pipx install foyou-http
使用
foyou-http # 共享当前目录,默认端口 5512
foyou-http ~/Downloads -p 8000 # 指定目录和端口
foyou-http -r # 只读共享
foyou-http -d -a admin:123456 # 允许重命名/删除,并开启密码
python -m foyou.http # 不安装命令也可以这样运行
启动后终端会显示本机和局域网访问地址:
foyou-http 0.1.0 已启动
共享目录 /home/me/share
本机访问 http://127.0.0.1:5512/
局域网 http://192.168.1.23:5512/
权限 浏览/下载 · 上传/新建
认证 未开启
命令行参数
| 参数 | 说明 |
|---|---|
dir |
共享目录,默认当前目录 |
-H, --host |
监听地址,默认 0.0.0.0(所有网卡);只给本机用可设为 127.0.0.1 |
-p, --port |
监听端口,默认 5512;0 表示随机端口 |
-r, --readonly |
只读模式,禁止上传、新建、重命名、删除 |
-d, --allow-delete |
允许重命名和删除(默认关闭) |
-a, --auth USER:PASS |
开启 HTTP Basic 认证;也可以用环境变量 FOYOU_HTTP_AUTH,避免密码出现在进程列表里 |
--max-size SIZE |
单次上传大小上限,如 500M、2G |
--show-hidden |
显示并允许访问隐藏文件(. 开头,或 Windows 隐藏属性) |
--cors |
允许跨域访问 |
-o, --open |
启动后自动打开浏览器 |
-q, --quiet |
不输出访问日志 |
-v, --version |
显示版本 |
快捷键
| 按键 | 作用 |
|---|---|
/ 或 Ctrl+F |
搜索当前目录 |
Backspace / Alt+↑ |
返回上一级 |
Ctrl+A |
全选 |
Ctrl + 点击、Shift + 点击 |
多选、连续选择 |
Delete / F2 |
删除 / 重命名选中项(需 --allow-delete) |
← → Esc |
预览时切换、关闭 |
命令行 / 脚本访问
# 下载(支持断点续传)
curl -O -C - http://host:5512/path/file.iso
# 上传到某个目录(可一次上传多个)
curl -F files=@a.txt -F files=@b.jpg http://host:5512/path/
# 获取目录列表 JSON
curl http://host:5512/path/?json
# 把整个目录打包下载
curl -o backup.zip "http://host:5512/path/?zip"
管理接口(JSON,POST):
| 接口 | 请求体 | 权限 |
|---|---|---|
/__foyou_http__/api/mkdir |
{"path": "/dir/", "name": "新文件夹"} |
上传 |
/__foyou_http__/api/rename |
{"path": "/dir/old.txt", "name": "new.txt"} |
--allow-delete |
/__foyou_http__/api/delete |
{"paths": ["/dir/a.txt", "/dir/b/"]} |
--allow-delete |
安全提示
foyou-http 面向局域网内的临时文件共享。默认监听所有网卡,同一网络中的人都能访问,并且可以上传文件。在不受信任的网络中,请使用 --auth 设置密码,或用 -r 只读共享。Basic 认证在 HTTP 下是明文传输,如果需要在公网使用,请在前面加一层 HTTPS 反向代理(如 Caddy、Nginx)。
开发
python -m venv .venv
.venv/bin/pip install -e ".[test]" # Windows: .venv\Scripts\pip
.venv/bin/pytest
许可证
GPL-3.0-or-later
Metadata
Release files for foyou-http 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| foyou_http-0.1.0.tar.gz | 74.7 kB | Without provenance | Details for foyou_http-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| foyou_http-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for foyou_http-0.1.0-py3-none-any.whl |
Total release size: 144.2 kB
Release files / foyou_http-0.1.0.tar.gz
| Download URL | foyou_http-0.1.0.tar.gz |
|---|---|
| Size | 74.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
897754c9aabfadb9d349e3da07309c02c33591ea942f1cf47d29accaae5c426d
|
|
BLAKE2b-256 checksum How to use checksums |
7b3119109495228b72e018c43fe66ea01853dd2e65cbcdc3d198a86fbe689610
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / foyou_http-0.1.0-py3-none-any.whl
| Download URL | foyou_http-0.1.0-py3-none-any.whl |
|---|---|
| Size | 69.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
724dce27c4afb4a23292fba3f4ee54ebd07a5062587bc66dcb2b0874c708e912
|
|
BLAKE2b-256 checksum How to use checksums |
f813c6e917b8b3d322f909c98f5d5a49141287fff0e17e9e061bec2715724fef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Security for foyou-http 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.