def addressbook_(): if request.method == "POST": name = request.form['name'] address = request.form['addr'] addressbook.add_entry(name, address) delete = request.form.getlist("delete") if delete: for x in delete: address_delete(x) return redirect("/addressbook/") try: addr_ = [] addresses = addressbook.addresses().replace("\t", '').split("\n") for x in addresses: try: if x != '': x = x.split() name = x[0] addre = x[1] addr_.append({"name":name, "addr":addre}) except IndexError: continue addresses = addr_ return render_template("addressbook.html", addresses=addresses, num=str(len(check())), addr=addr) except Exception, error: return render_template("addressbook.html", num=str(len(check())), addr=addr)
def do_addresses(self, line): self.lastcmd = "" print addressbook.addresses()