Skip to content

Instantly share code, notes, and snippets.

@chrisdone-artificial
Last active June 30, 2024 21:17
Show Gist options
  • Save chrisdone-artificial/266af35c02e739d7ce38501dbb55f5cf to your computer and use it in GitHub Desktop.
Save chrisdone-artificial/266af35c02e739d7ce38501dbb55f5cf to your computer and use it in GitHub Desktop.
hell-http.hs demo
#!/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