def GET(self): params = web.input() try: query = params.query #resultsAsDict = proxy.search(query) results = [{"sha":["123123123","12313213"], "name":["test"]}, {"sha":["00000000"], "name":["otroName"]} ] #results = [Foaf(f) for f in resultsAsDict] #print "FIXME Draw with template in HTML %i results" %( len(results)) try: render('results.html',{'results':results}) except Exception, e: print str(e) except AttributeError: web.header("Content-Type","text/html; charset=utf-8") render('form.html')
def POST(self): x = web.input(myfile={}) if not x.myfile.value: errmsg = "For some reason I can't read your file" return render.index(errmsg) try: data = reader.load_data(x.myfile.value) except ValueError: print >> sys.stderr, "Wrong file format from user" return render.index("Your file does not look like a JSON file.") # do the magic bookmark = reader.convert(data, False) # force browser to show "Save as" dialog. web.header('Content-Type', x.myfile.type) # file type web.header('Content-disposition', 'attachment; filename='+ x.myfile.filename + '.html') model.Increment().increment_users() return reader.dump_data(bookmark) # your blob