Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. import cherrypy
  2.  
  3.  
  4. @cherrypy.tools.register('before_finalize', priority=60)
  5. def noisy_hook_1():
  6. raise ValueError('hook 1 failed')
  7.  
  8.  
  9. @cherrypy.tools.register('before_finalize', priority=60)
  10. def noisy_hook_2():
  11. raise ValueError('hook 2 failed')
  12.  
  13.  
  14. class Server:
  15. config = {
  16. 'global': {
  17. 'server.socket_host': '::0',
  18. },
  19. '/': {
  20. 'tools.noisy_hook_1.on': True,
  21. 'tools.noisy_hook_1.failsafe': True,
  22. 'tools.noisy_hook_2.on': True,
  23. 'tools.noisy_hook_2.failsafe': True,
  24. }
  25. }
  26.  
  27. @cherrypy.expose
  28. def index(self):
  29. return "Hello World"
  30.  
  31. @classmethod
  32. def run(cls):
  33. cherrypy.quickstart(cls(), config=cls.config)
  34.  
  35.  
  36. __name__ == '__main__' and Server.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement