#!/usr/local/bin/python
import cgi, pydelicious, sys, urllib2
form = cgi.FieldStorage()
print "Content-type: text/html\n\n";
if not form.has_key("username") or not form.has_key("password"):
print "Need both username and password"
print form.keys()
sys.exit(0)
username = form["username"].value
password = form["password"].value
print ''
print '''
Uploading...
'''
def jsEscape(text, charset = None):
if type(text)==type(u""):
text= text.encode([charset, 'utf-8'][charset==None])
text = text.replace("\r", "\\r").replace("\n", "\\n")
text = text.replace('"', '\\"').replace("'", "\\'")
return "'" + text + "'"
api = pydelicious.apiNew(username, password)
posts = None
try:
posts = api.posts_all()
except urllib2.HTTPError:
print "Error talking to del.icio.us"
sys.exit(0)
print ''