Lightweight web server for client-side integration

I need to create a python module that will be installed on the target machines. One of the scripts in this module should be able to receive http POSTS (usually with some formatted JSON data in the body), and then pass this data to the corresponding python script. I can imagine two ways to do this:

  • Open the socket of the listening server on port 80, wait for this HTTP request to come in, analyze it and pass this data to another python script, depending on the URL that came. This method does not require the end user to install a web server. The end user must install the python module.

  • You have a mini web server installed along with the python module. The web server will do the same job as [a] via CGI, without having to write CGI functions. But then the user will have to install the web server (i.e. the problem of another installation). I would like to avoid this, if possible.

IF [b] is a simpler option , which is the smallest simplest web server: (preferably one that can be packaged as part of the python module itself, so it doesn't have to be installed separately). Of course, there must be open source.

+4
source share
1 answer

batteries included
Python 2
Python 3

+4
source

Source: https://habr.com/ru/post/1747699/


All Articles