Exemplo n.º 1
0
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)
Exemplo n.º 2
0
 def do_add_address(self, line):
     self.lastcmd = ""
     name = raw_input("Name: ")
     address = raw_input("Address: ")
     addressbook.add_entry(name, address)
Exemplo n.º 3
0
 def do_add_address(self, line):
     name = raw_input("Name: ")
     address = raw_input("Address: ")
     addressbook.add_entry(name, address)