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> --dir <root_directory> --debug <debug_mode>
--port <port_number>:设置服务器监听的端口号,默认为25000。--dir <root_directory>:设置文件上传和下载的根目录,默认为/data/。--debug <debug_mode>:设置调试模式,默认为True。
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> --dir <root_directory> --debug <debug_mode>
在Python 3环境下运行:
python3 -m whttpserver --port <port_number> --dir <root_directory> --debug <debug_mode>
配置
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.2.0.tar.gz
(3.7 kB
view details)
File details
Details for the file whttpserver-0.2.0.tar.gz.
File metadata
- Download URL: whttpserver-0.2.0.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a18c0ad4d73a8dc713ee1e82c2102c0c2e56af2dd0c63b9ab730884cda8cb698
|
|
| MD5 |
d66303e5e5fd8cd9ac35440be8ff4b3c
|
|
| BLAKE2b-256 |
1211861115e63b33ed6929c4e1a51f832f23de262197b75aef6ce593ffad2f7b
|