diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2013-10-02 13:44:17 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2013-10-02 13:44:17 +0200 |
commit | 7939df347f00e5e4faf4e6c2e75ff6885727f4c1 (patch) | |
tree | cc2f3fa3357cb95a4d58992df5c8f503f34e1436 | |
parent | 59e36cff8f646d6314e884e227d22bc09d52cc7f (diff) | |
download | cpaste-7939df347f00e5e4faf4e6c2e75ff6885727f4c1.tar.gz cpaste-7939df347f00e5e4faf4e6c2e75ff6885727f4c1.tar.xz cpaste-7939df347f00e5e4faf4e6c2e75ff6885727f4c1.zip |
Put the paste url into a variable and use https.
-rwxr-xr-x | cpaste | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -30,6 +30,10 @@ import json import requests from optparse import OptionParser + +paste_url = 'https://cpaste.org' + + parser = OptionParser() parser.add_option("-f", "--file", dest="filename", help="Read from a file instead of stdin", metavar="FILE") @@ -62,7 +66,7 @@ payload = {'data':''.join(paste_data), 'language': options.lang, 'private': opti # http content type headers = {'Content-Type': 'application/json'} -r = requests.post('http://cpaste.org/api/json/create', data=json.dumps(payload), headers=headers) +r = requests.post(paste_url + '/api/json/create', data=json.dumps(payload), headers=headers) result = json.loads(r.text)['result'] @@ -72,8 +76,8 @@ if result.get(u'error', None): hash = result.get(u'hash', None) if hash and len(hash) > 0: - print "https://cpaste.org/%(id)s/%(hash)s" % result + print paste_url + "/%(id)s/%(hash)s" % result else: - print "https://cpaste.org/%(id)s" % result + print paste_url + "/%(id)s" % result -# http://cpaste.org/api/json/create +sys.exit(0) |