Guest User

Untitled

a guest
Jun 21st, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import web
  4. from web import form
  5.  
  6. render = web.template.render('templates/address/')
  7.  
  8. urls = (
  9. "/add", "add_address",
  10. "/edit/([a-zA-Z0-9_]+)", "edit_address",
  11. "/show/([a-zA-Z0-9_]+)", "show_address"
  12. )
  13.  
  14. vphone = form.regexp(r".[0-9\-]", "must be numbers and dashes (-)")
  15.  
  16. add_form = form.Form(
  17. form.Textbox("address_id", description="Addres ID"),
  18. form.Textbox("phone", vphone, description="Phone"),
  19. form.Textbox("location", "Address"),
  20. form.Button("submit", type="submit", description="Add")
  21. )
  22.  
  23. class add_address:
  24. def GET(self):
  25. f = add_form()
  26. return render.add_address(f)
  27.  
  28. def POST(self):
  29. f = add_form()
  30. ## if not f.validates():
  31. return render.add_address(f)
  32. else:
  33. return render.add_address(f, True)
  34. #print "ALL OK!\n"
  35.  
  36. app_address = web.application(urls, globals())
  37.  
  38. if __name__ == "__main__": app_address.run()
Add Comment
Please, Sign In to add comment