Forget SimpleHTTPServer! This Emerging Python Library Makes Uploading and Downloading Easier

Introduction

whttpserver is a simple HTTP server, similar to <span>python -m http.server</span>, but adds file upload and editing capabilities, thus solving the confusion of its inability to upload files.

It can even start the server using the <span>whttpserver</span> command.

Why This Tool is Needed

Many company services are now accessed through jump servers, making it impossible to upload and download files using commands like rz, scp, etc. Additionally, there are many servers, some of which have Python 3 installed by default, while many older Linux servers still default to 2.7.5.

  • • Supports Python 2 and Python 3
  • • Compatible with Linux, macOS, and Windows operating systems
  • • Besides file browsing, it also supports file upload, download, and editing
  • • Allows specification of upload directory
  • • Allows specification of port number, default is 25000
  • • Can display records of recently uploaded files
  • • The page does not refresh after file upload, allowing for continuous uploads
  • • Simple and lightweight installation, no configuration required

Features

  • File Upload: Upload files to the specified directory on the server via the web interface.
  • File Download: Browse directories on the server and download files.
  • Directory Browsing: View files and subdirectories on the server.
  • File Editing: Edit files on the server.

Installing the Library

pip install whttpserver

Starting the Server

Run the server:

python -m whttpserver --port <port_number> --dir <root_directory> --debug <debug_mode>

Or

whttpserver --port <port_number> --dir <root_directory> --debug <debug_mode>

The simplest way to start

whttpserver
  • <span>--port <port_number></span>: Set the port number the server listens on, default is 25000.
  • <span>--dir <root_directory></span>: Set the root directory for file uploads and downloads, default is <span>/data/</span>.
  • <span>--debug <debug_mode></span>: Set the debug mode, default is <span>True</span>.

Python 2 and Python 3 Environments

whttpserver can run in both Python 2 and Python 3 environments, thus avoiding the awkwardness of not being able to upload and download on older servers.

Running in Python 2 environment:

python2 -m whttpserver --port <port_number> --dir <root_directory> --debug <debug_mode>

Running in Python 3 environment:

python3 -m whttpserver --port <port_number> --dir <root_directory> --debug <debug_mode>

Conclusion

This is the simplest and most convenient upload and download tool I have used. If you have better tools, please leave a comment!

Leave a Comment