A simple HTTP server like `python -m http.server`
Project description
whttpserver
whttpserver 是一个简单的HTTP服务器,类似于python -m http.server,但增加了文件上传和下载功能。
功能
- 文件上传:用户可以通过Web界面上传文件到服务器指定的目录。
- 文件下载:用户可以浏览服务器上的目录,并下载文件。
- 目录浏览:用户可以查看服务器上的文件和子目录。
安装
确保已安装Flask:
pip install flask
使用
运行服务器:
python -m whttpserver --port <port_number> --root <root_directory>
--port <port_number>:设置服务器监听的端口号,默认为25000。--root <root_directory>:设置文件上传和下载的根目录,默认为/data/。
Python 2 和 Python 3 环境
whttpserver 可以在Python 2和Python 3环境下运行。确保安装了Flask:
# Python 2
pip install flask
# Python 3
pip3 install flask
在Python 2环境下运行:
python2 -m whttpserver --port <port_number> --root <root_directory>
在Python 3环境下运行:
python3 -m whttpserver --port <port_number> --root <root_directory>
配置
UPLOAD_FOLDER:设置文件上传的目录,默认为/data/。
路由
/:显示根目录下的文件和目录。/upload:上传文件接口。/download/<filename>:下载指定文件。
注意事项
- 确保
UPLOAD_FOLDER目录存在,并具有写权限。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
whttpserver-0.1.2.tar.gz
(3.5 kB
view details)
File details
Details for the file whttpserver-0.1.2.tar.gz.
File metadata
- Download URL: whttpserver-0.1.2.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
894e03f1b2e3ecd533b2b34ae1cf75ed5e546462a79c3e7eea61c7ecfae1e1c5
|
|
| MD5 |
e4065bb27c65bdc635fb0f43ebc123ef
|
|
| BLAKE2b-256 |
75660390af301d2fd5b1e74761440f7eb526c32cf21bb2c8a023e9dcdbc49453
|