mirror of
https://github.com/DarrenOfficial/dpaste.git
synced 2024-11-15 08:02:54 +11:00
Merge pull request #1 from mgedmin/doc-improvements
Doc improvements: simplify Python code, show shell one-liner alternative
This commit is contained in:
commit
f479fd6614
1 changed files with 6 additions and 1 deletions
|
@ -16,9 +16,10 @@ import sys
|
||||||
def paste_code():
|
def paste_code():
|
||||||
request = urllib2.Request(
|
request = urllib2.Request(
|
||||||
'http://dpaste.de/api/',
|
'http://dpaste.de/api/',
|
||||||
urllib.urlencode([('content', ''.join(sys.stdin.readlines()))]),
|
urllib.urlencode([('content', sys.stdin.read())]),
|
||||||
)
|
)
|
||||||
response = urllib2.urlopen(request)
|
response = urllib2.urlopen(request)
|
||||||
|
# Strip surrounding quotes (NB: response has no trailing newline)
|
||||||
print response.read()[1:-1]
|
print response.read()[1:-1]
|
||||||
|
|
||||||
if __name__ == '__main__':
|
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>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>Usage: <code>cat foo.txt | dpaste</code></p>
|
||||||
|
|
||||||
|
<p>Or you could use <code>curl</code>:
|
||||||
|
<code>alias dpaste="curl -F 'content=<-' http://dpaste.de/api/</code></p>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue