Skip to content

Instantly share code, notes, and snippets.

@codezixo
Forked from snoyberg/check-status.hs
Created June 15, 2020 00:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codezixo/e11cd1a08229333b5c7c3187e98edef2 to your computer and use it in GitHub Desktop.
Save codezixo/e11cd1a08229333b5c7c3187e98edef2 to your computer and use it in GitHub Desktop.
Check HTTP status codes
#!/usr/bin/env stack
-- stack --resolver lts-15.10 script
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE NoImplicitPrelude #-}
import RIO
import Network.HTTP.Simple
import qualified RIO.Text as T
main :: IO ()
main = runSimpleApp $ do
text <- readFileUtf8 "foo.txt"
let urls = T.lines text
logInfo "Status Code,URL"
for_ urls $ \url -> do
req <- parseRequest $ T.unpack url
res <- httpNoBody req
logInfo $ display (getResponseStatusCode res) <> "," <> display url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment