Skip to content

Instantly share code, notes, and snippets.

@utecht
Created December 3, 2013 16:42
Show Gist options
  • Save utecht/7772574 to your computer and use it in GitHub Desktop.
Save utecht/7772574 to your computer and use it in GitHub Desktop.
import requests
import sys
import webbrowser
from base64 import b64encode
api_key = 'c4622163d7339fe'
headers = {"Authorization": "Client-ID {}".format(api_key)}
url = "https://api.imgur.com/3/upload.json"
f = sys.argv[1]
j1 = requests.post(
url,
headers = headers,
data = {
'key': api_key,
'image': b64encode(open(f, 'rb').read()),
'type': 'base64',
'name': f,
'title': 'Picture no. 1'
}
)
if(j1.json()['success']):
webbrowser.open(j1.json()['data']['link'])
else:
print(j1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment