From d66151e50eadc08be94f95e4d91c2c64b10ccd05 Mon Sep 17 00:00:00 2001 From: Marius Gedminas Date: Tue, 22 Oct 2013 11:09:46 +0300 Subject: [PATCH] Fix example in about to handle the new newline This is hard to read due to the syntax highlighing; the diff is - # Strip surrounding quotes (NB: response has no trailing newline) + # Strip surrounding quotes - print response.read()[1:-1] + print response.read().strip()[1:-1] --- dpaste/templates/dpaste/about.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dpaste/templates/dpaste/about.html b/dpaste/templates/dpaste/about.html index b2ed280..c657638 100644 --- a/dpaste/templates/dpaste/about.html +++ b/dpaste/templates/dpaste/about.html @@ -18,7 +18,7 @@

API

{# Just put the script in dpaste and copy the source node #} -
  1. #!/usr/bin/env python
  2.  
  3. import urllib
  4. import urllib2
  5. import sys
  6.  
  7. def paste_code():
  8. request = urllib2.Request(
  9. 'https://dpaste.de/api/',
  10. urllib.urlencode([('content', sys.stdin.read())]),
  11. )
  12. response = urllib2.urlopen(request)
  13. # Strip surrounding quotes (NB: response has no trailing newline)
  14. print response.read()[1:-1]
  15.  
  16. if __name__ == '__main__':
  17. paste_code()
+
  1. #!/usr/bin/env python
  2.  
  3. import urllib
  4. import urllib2
  5. import sys
  6.  
  7. def paste_code():
  8. request = urllib2.Request(
  9. 'https://dpaste.de/api/',
  10. urllib.urlencode([('content', sys.stdin.read())]),
  11. )
  12. response = urllib2.urlopen(request)
  13. # Strip surrounding quotes
  14. print response.read().strip()[1:-1]
  15.  
  16. if __name__ == '__main__':
  17. paste_code()

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

Usage: cat foo.txt | dpaste