-
-
Save chrisdone/effad6ac7b9d0ae1355339c5a38cd66c to your computer and use it in GitHub Desktop.
hell-http.hs demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env hell | |
-- How to run this: | |
-- | |
-- socat TCP-LISTEN:8081,fork,reuseaddr,max-children=20 EXEC:"./handler.hell" | |
main = do | |
line <- Text.getLine | |
let content = | |
Text.concat ["<h1>Hello, World!</h1><p>This is generated by Hell.</p><pre>", line, "</pre>"] | |
Text.putStrLn $ | |
Text.intercalate | |
"\r\n" | |
[ | |
"HTTP/1.1 200 OK", | |
"Content-Type: text/html", | |
Text.concat ["Content-Length: ", Int.show (Text.length content)], | |
"", | |
content | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment