def submit(self, code=None):
if not code: raise NoCodeError()
# post the form to bpaste.net
body = urlencode(dict(code=code, lexer=self.lexer, expiry=self.expiry))
try:
response, content = self.http.request(self.url, 'POST', body=body, headers=self.headers)
except ServerNotFoundError:
raise CodeUploadError(-1, None)
# check the response
if response.status == 302 and response['location']:
return response['location']
raise CodeUploadError(response.status, content)
评论列表
文章目录