From 4e6352331f173fe67a950c759777091ab425d608 Mon Sep 17 00:00:00 2001 From: Marius Gedminas Date: Wed, 6 Mar 2013 13:18:38 +0200 Subject: [PATCH 1/2] Simplify/explain example code --- pastebin/templates/about.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pastebin/templates/about.html b/pastebin/templates/about.html index 956a851..cd6b76e 100644 --- a/pastebin/templates/about.html +++ b/pastebin/templates/about.html @@ -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__': From 741d9262012dcbde1221d918cfc46496ef789760 Mon Sep 17 00:00:00 2001 From: Marius Gedminas Date: Wed, 6 Mar 2013 13:18:54 +0200 Subject: [PATCH 2/2] Mention a shell alias alternative using curl --- pastebin/templates/about.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pastebin/templates/about.html b/pastebin/templates/about.html index cd6b76e..93e126e 100644 --- a/pastebin/templates/about.html +++ b/pastebin/templates/about.html @@ -27,6 +27,10 @@ if __name__ == '__main__':

Save this script in /usr/local/bin/dpaste and chmod +x ..filepath.

Usage: cat foo.txt | dpaste

+ +

Or you could use curl: +alias dpaste="curl -F 'content=<-' http://dpaste.de/api/

+ {% endblock %}