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 #}
- - #!/usr/bin/env python
-
- import urllib
- import urllib2
- import sys
-
- def paste_code():
- request = urllib2.Request(
- 'https://dpaste.de/api/',
- 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__':
- paste_code()
+ - #!/usr/bin/env python
-
- from urllib import urlencode
- from urllib2 import Request, urlopen
- from sys import stdin
-
- def paste_code():
- request = Request('https://dpaste.de/api/', urlencode({
- 'content': stdin.read(),
- 'lexer': 'python',
- 'format': 'url',
- }))
- print urlopen(request).read()
-
- if __name__ == '__main__':
- 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/"