Skip to content

Instantly share code, notes, and snippets.

@snoyberg
Created May 27, 2020 06:13
Show Gist options
  • Save snoyberg/61d93087936ba473623dead239c29ba1 to your computer and use it in GitHub Desktop.
Save snoyberg/61d93087936ba473623dead239c29ba1 to your computer and use it in GitHub Desktop.

Revisions

  1. snoyberg created this gist May 27, 2020.
    17 changes: 17 additions & 0 deletions check-status.hs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    #!/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