Merge pull request #1 from mgedmin/doc-improvements

Doc improvements: simplify Python code, show shell one-liner alternative
This commit is contained in:
Martin Mahner 2013-03-19 02:21:35 -07:00
commit f479fd6614

View file

@ -16,9 +16,10 @@ import sys
def paste_code():
request = urllib2.Request(
'http://dpaste.de/api/',
urllib.urlencode([('content', ''.join(sys.stdin.readlines()))]),
urllib.urlencode([('content', sys.stdin.read())]),
)
response = urllib2.urlopen(request)
# Strip surrounding quotes (NB: response has no trailing newline)
print response.read()[1:-1]
if __name__ == '__main__':
@ -26,6 +27,10 @@ if __name__ == '__main__':
<p>Save this script in <code>/usr/local/bin/dpaste</code> and <code>chmod +x ..filepath</code>.</p>
<p>Usage: <code>cat foo.txt | dpaste</code></p>
<p>Or you could use <code>curl</code>:
<code>alias dpaste="curl -F 'content=&lt;-' http://dpaste.de/api/</code></p>
{% endblock %}