Python-based WebServer

The main function of WebServer is to run the code, handle http requests and other services, such as common Apache, IIS, Nginx, etc. can be used to parse the code and process the request. The above kinds of containers (middleware) are powerful, but the installation configuration is troublesome. For a rookie like me, it may take a few days to set up a web server. If we’re building a web server that’s not designed to handle large-scale requests, but just for testing, then a quick and easy WebServer is critical.

Introduction to Python WebServer Programming

  • BaseHTTPServer: Provides basic web services and handler classes, namely HTTPServer and BaseHTTPRequestHandler.
  • SimpleHTTPServer: Contains the SimpleHTTPRequestHandler class that performs GET and HEAD requests.
  • CGIHTTPServer: Contains classes for handling POST requests and executing CGIHTTPRequestHandler
python -m SimpleHTTPServer 8000

Python built a lot of useful libraries, open the browser at this time, access localhost: 8000 port.

Introduction to PyWebServer

Since it’s very convenient to build a simple WebServer with python, I wrote a simple launcher, similar to SimpleHTTPServer. In order to facilitate the startup of the windows machine without the python environment, use the pyinstaller tool to package the py program into an exe executable.

Running the code under Linux
python -h
Python -i -p 8888 ##Specify ip and port, default is 8888
Running code under windows
PyWebServer.exe -h
PyWebServer.exe -p 8888 ##Specify the port, the default is 8888

After running, you can access it on other machines and download files!

PyWebServer function

The function can be imagined to play freely, for example:

  • You can run programs on the server, parse a well-constructed py code, and execute system commands remotely. (If you are not on the same network segment, you need to forward the port)
  • You can run the program on the server, instead of FTP and other tools, download the files on the server (when the server is linux, it is convenient to use)

Tools Download

PyWebServer [download address] (

本文标题:Python-based WebServer


发布时间:2016年09月14日 - 15:09

最后更新:2019年08月16日 - 15:08

原始链接: WebServer/

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。

nmask wechat