Last active
June 30, 2024 21:17
-
-
Save chrisdone-artificial/266af35c02e739d7ce38501dbb55f5cf 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