Uploaded Test files
This commit is contained in:
parent
f584ad9d97
commit
2e81cb7d99
16627 changed files with 2065359 additions and 102444 deletions
56
venv/Lib/site-packages/notebook/services/api/handlers.py
Normal file
56
venv/Lib/site-packages/notebook/services/api/handlers.py
Normal file
|
@ -0,0 +1,56 @@
|
|||
"""Tornado handlers for api specifications."""
|
||||
|
||||
# Copyright (c) Jupyter Development Team.
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
|
||||
import json
|
||||
import os
|
||||
|
||||
from tornado import gen, web
|
||||
|
||||
from ...base.handlers import IPythonHandler, APIHandler
|
||||
from notebook._tz import utcfromtimestamp, isoformat
|
||||
from notebook.utils import maybe_future
|
||||
|
||||
|
||||
class APISpecHandler(web.StaticFileHandler, IPythonHandler):
|
||||
|
||||
def initialize(self):
|
||||
web.StaticFileHandler.initialize(self, path=os.path.dirname(__file__))
|
||||
|
||||
@web.authenticated
|
||||
def get(self):
|
||||
self.log.warning("Serving api spec (experimental, incomplete)")
|
||||
return web.StaticFileHandler.get(self, 'api.yaml')
|
||||
|
||||
def get_content_type(self):
|
||||
return 'text/x-yaml'
|
||||
|
||||
|
||||
class APIStatusHandler(APIHandler):
|
||||
|
||||
_track_activity = False
|
||||
|
||||
@web.authenticated
|
||||
@gen.coroutine
|
||||
def get(self):
|
||||
# if started was missing, use unix epoch
|
||||
started = self.settings.get('started', utcfromtimestamp(0))
|
||||
started = isoformat(started)
|
||||
|
||||
kernels = yield maybe_future(self.kernel_manager.list_kernels())
|
||||
total_connections = sum(k['connections'] for k in kernels)
|
||||
last_activity = isoformat(self.application.last_activity())
|
||||
model = {
|
||||
'started': started,
|
||||
'last_activity': last_activity,
|
||||
'kernels': len(kernels),
|
||||
'connections': total_connections,
|
||||
}
|
||||
self.finish(json.dumps(model, sort_keys=True))
|
||||
|
||||
|
||||
default_handlers = [
|
||||
(r"/api/spec.yaml", APISpecHandler),
|
||||
(r"/api/status", APIStatusHandler),
|
||||
]
|
Loading…
Add table
Add a link
Reference in a new issue