diff --git a/dpaste/templates/dpaste/about.html b/dpaste/templates/dpaste/about.html index ad6c8d6..74b2eb6 100644 --- a/dpaste/templates/dpaste/about.html +++ b/dpaste/templates/dpaste/about.html @@ -18,14 +18,17 @@

API

+

dpaste provides a simple API documented in detail + on this page. For a quick start here is a code example (Python 2.x):

+ {# 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. from urllib import urlencode
  4. from urllib2 import Request, urlopen
  5. from sys import stdin
  6.  
  7. def paste_code():
  8.     request = Request('https://dpaste.de/api/', urlencode({
  9.         'content': stdin.read(),
  10.         'lexer': 'python',
  11.         'format': 'url',
  12.     }))
  13.     print urlopen(request).read()
  14.  
  15. if __name__ == '__main__':
  16.     paste_code()

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

Usage: cat foo.txt | dpaste

-

Or you could use curl: +

An alternative would be to just use curl: alias dpaste="curl -F 'content=<-' https://dpaste.de/api/"