Created
May 26, 2018 17:43
-
-
Save frenata/9fe6f0cf3c9b0567b4a94667b665bb46 to your computer and use it in GitHub Desktop.
http headers in coconut
This file contains hidden or 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
import sys | |
import requests as req | |
def get(url) = | |
outputs |> fmap$(print) where: | |
result = url |> req.get | |
status = (result | |
|> .status_code | |
|> "Status Code: {}".format$()) | |
headers = (result | |
|> .headers | |
|> .items() | |
|> starmap$((k,v) -> "{}: {}".format(k,v)) | |
|> list | |
|> sorted) | |
body = "\n" + result.text$[:500] | |
outputs = [status] + headers + [body] | |
def main() = get .. sys.argv[] <| 1 | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment