Skip to content

Instantly share code, notes, and snippets.

@johntyree
Created October 17, 2012 16:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johntyree/3906697 to your computer and use it in GitHub Desktop.
Save johntyree/3906697 to your computer and use it in GitHub Desktop.
Post to codepad.org from file or stdin.
#!/usr/bin/env python
import urllib
import urllib2
import sys
if len(sys.argv) > 1:
lang = sys.argv[1]
else:
lang = "Plain Text"
if len(sys.argv) > 2:
code = open(sys.argv[2]).read()
else:
code = sys.stdin.read().strip()
url = 'http://codepad.org'
values = {'lang' : lang,
'code' : code,
'run' : True,
'submit':'Submit'}
data = urllib.urlencode(values)
req = urllib2.Request(url, data)
response = urllib2.urlopen(req)
print response.url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment