To create an HTTP server in Python, you can make use of the built-in http.server
module. Here's an example of how to create a simple server that listens on port 8000:
main.py221 chars11 lines
To read the request body as HTML, you'll need to access the stdin
attribute of the request object. Here's an example code snippet that shows how to read the request body as HTML:
main.py293 chars9 lines
This handler assumes that the request is a POST
request, and reads the request body from the rfile
attribute of the request object. It then decodes the body as UTF-8 and prints it to the console. You can modify this code to suit your specific needs.
gistlibby LogSnag