Moved haste() to util/web
This commit is contained in:
parent
23dde386d0
commit
c44b1dcd6a
2 changed files with 11 additions and 10 deletions
|
@ -1,14 +1,7 @@
|
|||
import http
|
||||
import http, web
|
||||
import json, urllib2, sys
|
||||
|
||||
|
||||
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']))
|
||||
|
||||
|
||||
def eval_py(code, paste_multiline=True):
|
||||
while True:
|
||||
output = http.get("http://eval.appspot.com/eval", statement=code).rstrip('\n')
|
||||
|
@ -23,6 +16,6 @@ def eval_py(code, paste_multiline=True):
|
|||
status = "Code executed sucessfully: "
|
||||
|
||||
if "\n" in output and paste_multiline:
|
||||
return status + haste(output)
|
||||
return status + web.haste(output)
|
||||
else:
|
||||
return output
|
|
@ -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