CherryPy
    
    
    Publish date: Aug 13, 2019
    
      
      
Last updated: Apr 22, 2020
  
    
  
  
  
  
  
  
  
  
    
  
  
  
  
Last updated: Apr 22, 2020
- Dispatching
 - is the art of locating the appropriate page handler for a given request
 - Usually, dispatching is based on the request’s URL, the query-string and, sometimes, the request’s method (GET, POST, etc.)
 - hook
 - A hook point is a point during the request/response processing “on_start_resource” - The earliest hook; the Request-Line and request headers have been processed and a dispatcher has set request.handler and request.config.
 - before_request_body
 - before_handler
 - before_finalize
 - on_end_resource
 - before_error_response
 - after_error_response
 - on_end_request
 - Plugins
 - Plugins, simply put, are entities that play with the bus, either by publishing or subscribing to channels, usually both at the same time.
 - create your own plugins
 - enable/disable a plugin
 
- Micro web frameworks, 
bottle,flask,web2py - Minimal framework for creating APIs
 - Very fast, netflix uses it to route traffic b/w datacentres, disney, splunk
 - came in 2002, relatively old
 - Class name is usually the 
routeof application - Bulitin HTTP server 
cherrypy.quickstarthas handlers foruWSGI, development server, tornado application, tie into Django - HTTP server mounts the class which has index method in it.
 cherrypy.toolsare like Django middleware. Can manupulate response before or after you are done with it.- tools to upload/download file
 - Configs
- Application level, mostly routing, specifying static folder location, manually changing header
 - what HTTP server do we use? which port?
 
 - Make your won cherry tools using 
@cherrypy.tools.register('before_habdler')- 8 hooks provided by cherrypy to insert handler
 
 - Route 
graftingcan have multiple SPA running on same URL - minimalistic server is 6 lines of code
 - Support 
FCGIandlighthttpdserver mode - Multiple apps could be mounted at different routes
 - Process monitoring with 
supervisord - A HTTP/1.1-compliant, WSGI thread-pooled webserver.[4] Typically, CherryPy itself takes only 1–2 ms per page.
 - CherryPy 3 has fastest WSGI server yet 12/23/06
 - CherryPy uses a tree-based mapper which does not accommodate well with segments that have no physical reality as a Python object
 
most arcane standard library module
- Most ingolorious programmers start with print statements unless it hits them in face
 - By default would show only the warning, why worry about things which are going good.
 - logging module assumes a lot of things
 - Handler to make HTTP POST calls of standard logging events
 
FORMAT = '[%(asctime)s] - [%(levelname)s] - %(message)s'
logging.basicConfig(
    level=logging.INFO,
    format=FORMAT
)
- Everything info level and above, default is warning level and above.
 - Give us more infomration that we did not put in
 
- Send JSON / HTML response
 - Accept JSON input request