Created
June 3, 2019 20:17
-
-
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)
This file contains 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 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