Here's an example code snippet that creates an HTTP server in Ruby and reads the request body as HTML:
main.rb526 chars24 lines
This code listens for incoming connections on port 3000, accepts the connection and reads the request headers and body. It then prints the request body (assuming that it's HTML). Finally, it sends a basic "Hello, world!" HTML response back to the client.
Note that this is a very basic example, and doesn't handle errors or multiple requests at the same time.
gistlibby LogSnag