Skip to main content

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


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

Uploaded Source

File details

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

File metadata

  • Download URL: whttpserver-0.1.3.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

Hashes for whttpserver-0.1.3.tar.gz
Algorithm Hash digest
SHA256 d8cf07f1783b46fa1ec81aac9267eb7077e2db112ec357151b5dc9ea7fefec42
MD5 49125b1b7804880149deeb5960617462
BLAKE2b-256 f6e76d4737370c6085aa46b6f123f4ff36365422c6c00d9ab13cf1a49179492c

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