-
-
Save Akasurde/7b5bae894370dbe4f2c42307736ebc14 to your computer and use it in GitHub Desktop.
Hastebin Python Client
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Usage: | |
$ cat hastebin.py | ./hastebin.py | |
http://hastebin.com/KEY | |
$ ./hastebin.py hastebin.py | |
http://hastebin.com/KEY | |
""" | |
import json, requests, sys | |
URL = "http://hastebin.com" | |
if sys.stdin.isatty(): | |
with open(sys.argv[1], 'r') as filedata: | |
data = "".join(filedata.readlines()).strip() | |
else: | |
data = "".join(sys.stdin.readlines()).strip() | |
response = requests.post(URL + "/documents", data) | |
sys.stdout.write("%s/%s\n" % (URL, json.loads(response.text)['key'])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment