Skip to content

Instantly share code, notes, and snippets.

@ragne
Created August 18, 2020 16:19
Show Gist options
  • Save ragne/c39e2296ff3be6fd726c20be3375ee35 to your computer and use it in GitHub Desktop.
Save ragne/c39e2296ff3be6fd726c20be3375ee35 to your computer and use it in GitHub Desktop.

HTTP status getter

Write a terminal application in Python 3 to get a random or user-specified picture from https://http.cat/ with following abilities:

  • get a random status or get user-defined status (via command-line flag; random is default)
  • save it locally in temporary directory
  • and open said image in user's browser

Also program should have:

  • Logging of actions, should log WARN by default with cmdline flag to increase level to DEBUG (-v)
  • Linting enabled and passed
  • Auto-formatting enabled with black
  • setup.py installation script to install it on *NIX system

Possible command line flags:

./httpcat.py a program to get cat picture for a http status
    -h show this help
    -v increase logging to DEBUG level
    -s (--status) specify http status to get (DONT forget validation!!)

Notes:

To open a browser with a picture save it as .jpg file and use open $path_to_file

Acceptance of work

Completed work should be presented as github/bitbucket repo. If time allows you can also research CI solutions for your platform and implement simple pipeline which would:

  • create a virtualenv with all dependencies (use venv/virtualenv/pipenv)
  • run a test (yes, you have to write one :)
  • build a package with setup.py
  • celebrate!

Alternatively all pipeline above can either be expressed as bash script or a Makefile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment