Skip to content

Instantly share code, notes, and snippets.

@24Ryou
Last active November 11, 2022 18:24
Show Gist options
  • Save 24Ryou/9f2429187454ec59ab0d161d514276b5 to your computer and use it in GitHub Desktop.
Save 24Ryou/9f2429187454ec59ab0d161d514276b5 to your computer and use it in GitHub Desktop.
make url shorten
import requests
from decouple import config
import urllib
def shortURL(URL):
key = config('CUTTLY_TOKEN')
parsedURL = urllib.parse.quote(URL)
r = requests.get('http://cutt.ly/api/api.php?key={}&short={}'.format(key, parsedURL))
data = r.json()
return data['url']['shortLink']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment