Skip to content

TSharvananthan/quack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quack

Quackify your terminal with 13 lines of code!

Overview

This is a short Python program that randomly generates a duck image.

TLDR

One can replicate the process in a few steps

  1. Create a new project directory and add a quack.py program
  2. Run pip3 install requests Pillow pyinstaller
  3. Open quack.py and add
from PIL import Image
import requests
  1. Send a GET request to get a random URL by adding
r = requests.get("https://random-d.uk/api/random")
r_json = r.json()
quack = r_json["url"]
  1. Get the raw duck image data with another GET request (this time, passing stream=True)
r2 = requests.get(quack, stream=True)
r2_raw = r2.raw
  1. Show the image using PIL
im = Image.open(r2_raw)
im.show()
  1. Run pyinstaller --onefile quack.py

  2. Remove the build directory, move the executable out of dist, remove quack.spec and dist

  3. Add the final executable to PATH.

  4. You can now type quack into the command line and get a duck image

About

Code for my "Quackify Your Terminal With 13 Lines Of Code" blog post

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages