Advertisement
andrewb

web_test.py

Jun 25th, 2016
428
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. import web
  2. import simplejson as json
  3.  
  4. urls = (
  5.     '/', 'index',
  6.     '/url', 'url',
  7.     '/math', 'math'
  8. )
  9.  
  10. class index:
  11.     def GET(self):
  12.         return 'hello, world'
  13.  
  14. class url:
  15.     def GET(self):
  16.         return 'url'
  17.  
  18. class math:
  19.     def GET(self):
  20.         return 'do math'
  21.    
  22.     def POST(self):
  23.         data = web.data()
  24.         j = json.loads(data)
  25.         print j
  26.         return j['a']+j['b']
  27.    
  28. if __name__ == "__main__":
  29.     app = web.application(urls, globals())
  30.     app.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement