You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			31 lines
		
	
	
		
			676 B
		
	
	
	
		
			Python
		
	
			
		
		
	
	
			31 lines
		
	
	
		
			676 B
		
	
	
	
		
			Python
		
	
"""HTTP handler to shut down the Jupyter server."""
 | 
						|
 | 
						|
from tornado import ioloop, web
 | 
						|
 | 
						|
from jupyter_server.auth.decorator import authorized
 | 
						|
from jupyter_server.base.handlers import JupyterHandler
 | 
						|
 | 
						|
AUTH_RESOURCE = "server"
 | 
						|
 | 
						|
 | 
						|
class ShutdownHandler(JupyterHandler):
 | 
						|
    """A shutdown API handler."""
 | 
						|
 | 
						|
    auth_resource = AUTH_RESOURCE
 | 
						|
 | 
						|
    @web.authenticated
 | 
						|
    @authorized
 | 
						|
    async def post(self):
 | 
						|
        """Shut down the server."""
 | 
						|
        self.log.info("Shutting down on /api/shutdown request.")
 | 
						|
 | 
						|
        if self.serverapp:
 | 
						|
            await self.serverapp._cleanup()
 | 
						|
 | 
						|
        ioloop.IOLoop.current().stop()
 | 
						|
 | 
						|
 | 
						|
default_handlers = [
 | 
						|
    (r"/api/shutdown", ShutdownHandler),
 | 
						|
]
 |