Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.61 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. import cherrypy
  3.  
  4. class Contact:
  5.     username = str
  6.  
  7.     def __init__(self, username=None):
  8.         self.username = username
  9.        
  10.     @cherrypy.expose
  11.     def index(self):
  12.         return str(self.username)
  13.  
  14.     @cherrypy.expose
  15.     def edit(self, newUsername):
  16.         if(newUsername):
  17.             return 'change ' + self.username + ' to ' + newUsername
  18.         return 'please supply a newUsername for ' + username
  19.  
  20.     @cherrypy.expose
  21.     def delete(self):
  22.         return 'delete ' + self.username
  23.        
  24. class Root:
  25.     @cherrypy.expose
  26.     def default(self):
  27.         return 'index'
  28.     def _cp_dispatch(self, vpath):
  29.         return Contact(username=vpath[0])
  30.  
  31. cherrypy.quickstart(Root())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement