- syntax = 'text'
- if len(sys.argv) > 1:
- title = sys.argv[1]
- else:
- title = "The loser %s didn't even add a title" % poster
- form = (('poster', poster), ('title', title), ('syntax', syntax), ('content', sys.stdin.read()))
- response = http_post_form_with_auth(paste_host, paste_path, form)
- location = response.getheader('Location')
+
+ parser = ArgumentParser()
+ parser.add_argument("-f", "--format", default="text", help="format of paste")
+ parser.add_argument("title", default="The loser %s didn't even add a title" % poster, nargs="?")
+ args = parser.parse_args()
+
+ form = (('poster', poster), ('title', args.title), ('syntax', args.format), ('content', sys.stdin.read()))
+ response = requests.post('https://%s/%s' % (paste_host, paste_path.lstrip('/')), data=form, allow_redirects=False)
+ location = response.headers['Location']