2014-10-30 14:43:22 +08:00
|
|
|
#encoding: utf-8
|
2014-09-30 08:59:54 +08:00
|
|
|
"""Tornado handlers for the terminal emulator."""
|
|
|
|
|
|
|
|
# Copyright (c) IPython Development Team.
|
|
|
|
# Distributed under the terms of the Modified BSD License.
|
|
|
|
|
2014-10-26 08:10:41 +08:00
|
|
|
import tornado
|
2014-09-30 08:59:54 +08:00
|
|
|
from tornado import web
|
2014-09-30 10:15:59 +08:00
|
|
|
import terminado
|
2014-09-30 08:59:54 +08:00
|
|
|
from ..base.handlers import IPythonHandler
|
|
|
|
|
|
|
|
class TerminalHandler(IPythonHandler):
|
2014-10-04 03:37:26 +08:00
|
|
|
"""Render the terminal interface."""
|
2014-09-30 08:59:54 +08:00
|
|
|
@web.authenticated
|
2014-10-04 03:37:26 +08:00
|
|
|
def get(self, term_name):
|
|
|
|
self.write(self.render_template('terminal.html',
|
|
|
|
ws_path="terminals/websocket/%s" % term_name))
|
2014-09-30 08:59:54 +08:00
|
|
|
|
2014-10-06 03:12:33 +08:00
|
|
|
class TermSocket(terminado.TermSocket, IPythonHandler):
|
|
|
|
def get(self, *args, **kwargs):
|
|
|
|
if not self.get_current_user():
|
|
|
|
raise web.HTTPError(403)
|
2014-11-08 14:30:20 +08:00
|
|
|
return super(TermSocket, self).get(*args, **kwargs)
|
2014-10-31 09:38:31 +08:00
|
|
|
|
|
|
|
def clear_cookie(self, *args, **kwargs):
|
|
|
|
"""meaningless for websockets"""
|
|
|
|
pass
|
2014-10-26 08:10:41 +08:00
|
|
|
|