Skip to main content

A simple HTTP server like `python -m http.server`

Project description

whttpserver

whttpserver 是一个简单的HTTP服务器,类似于python -m http.server,但增加了文件上传和下载功能。

功能

  • 文件上传:用户可以通过Web界面上传文件到服务器指定的目录。
  • 文件下载:用户可以浏览服务器上的目录,并下载文件。
  • 目录浏览:用户可以查看服务器上的文件和子目录。

安装

如果没有pip,可以先安装pip,python2的安装方式如下:

wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
python get-pip.py

python3的安装方式如下:

wget https://bootstrap.pypa.io/get-pip.py
python3 get-pip.py

使用

运行服务器:

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


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.8.0.tar.gz (4.7 kB view details)

Uploaded Source

File details

Details for the file whttpserver-0.8.0.tar.gz.

File metadata

  • Download URL: whttpserver-0.8.0.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for whttpserver-0.8.0.tar.gz
Algorithm Hash digest
SHA256 1e20ec29a0c2956dc7e3488e161c396563331d04aeab312f679c94742d137ad7
MD5 3f886417898df4fad3e633b088213f81
BLAKE2b-256 d04e665cb1e79a571877e07971ff3c68a7c918c2390afd5c462aae886743ce50

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page