Moved haste() to util/web
This commit is contained in:
parent
23dde386d0
commit
c44b1dcd6a
2 changed files with 11 additions and 10 deletions
|
@ -1,6 +1,7 @@
|
|||
""" web.py - handy functions for web services """
|
||||
|
||||
import http, urlnorm
|
||||
import json, urllib2
|
||||
from urllib import urlencode
|
||||
|
||||
|
||||
|
@ -28,4 +29,11 @@ def isgd(url):
|
|||
""" shortens a URL with the is.gd PAI """
|
||||
url = urlnorm.normalize(url.encode('utf-8'))
|
||||
params = urlencode({'format': 'simple', 'url': url})
|
||||
return http.get("http://is.gd/create.php?%s" % params)
|
||||
return http.get("http://is.gd/create.php?%s" % params)
|
||||
|
||||
|
||||
def haste(data):
|
||||
URL = "http://paste.dmptr.com"
|
||||
request = urllib2.Request(URL + "/documents", data)
|
||||
response = urllib2.urlopen(request)
|
||||
return("%s/%s" % (URL, json.loads(response.read())['key']))
|
Reference in a new issue