Skip to content

Instantly share code, notes, and snippets.

@chrisdone
Forked from chrisdone-artificial/hell-http.hs
Created June 30, 2024 21:17
Show Gist options
  • Save chrisdone/effad6ac7b9d0ae1355339c5a38cd66c to your computer and use it in GitHub Desktop.
Save chrisdone/effad6ac7b9d0ae1355339c5a38cd66c 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