Skip to content

Instantly share code, notes, and snippets.

@lorcalhost
Created June 3, 2019 20:17
Show Gist options
  • Save lorcalhost/d7c16df1677ebbf98a77755e00b975f8 to your computer and use it in GitHub Desktop.
Save lorcalhost/d7c16df1677ebbf98a77755e00b975f8 to your computer and use it in GitHub Desktop.
Unsplash random picture at boot (On run it downloads the picture in next_image.png)
import shutil
import requests
url = 'https://source.unsplash.com/1600x900/?food'
try:
response = requests.get(url, stream=True)
if response.status_code is 200:
shutil.copyfile('next_image.png', 'current_image.png')
with open('next_image.png', 'wb') as out_file:
shutil.copyfileobj(response.raw, out_file)
del response
except:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment