To return a text response from a HTTP server in Ruby, you can use the following code:
main.rb221 chars13 lines
This code listens for incoming connections on port 8080, reads the request from the client, sends a HTTP response with a plain text content type, and closes the connection. The response body is "Hello, World!" which can be changed to any other text.
gistlibby LogSnag