commit
39b756bf34
@ -0,0 +1,30 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>{{page_title}}</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<style type="text/css">
|
||||
html, body, #container {
|
||||
height: 100%;
|
||||
}
|
||||
body, #container {
|
||||
overflow: hidden;
|
||||
margin: 0;
|
||||
}
|
||||
#iframe {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border: none;
|
||||
}
|
||||
</style>
|
||||
<div id="container">
|
||||
<iframe id="iframe" sandbox="allow-scripts" src="/files/{{file_path}}"></iframe>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@ -0,0 +1,26 @@
|
||||
#encoding: utf-8
|
||||
"""Tornado handlers for viewing HTML files."""
|
||||
|
||||
# Copyright (c) Jupyter Development Team.
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
|
||||
from tornado import web
|
||||
from ..base.handlers import IPythonHandler, path_regex
|
||||
from ..utils import url_escape
|
||||
|
||||
class ViewHandler(IPythonHandler):
|
||||
"""Render HTML files within an iframe."""
|
||||
@web.authenticated
|
||||
def get(self, path):
|
||||
path = path.strip('/')
|
||||
if not self.contents_manager.file_exists(path):
|
||||
raise web.HTTPError(404, u'File does not exist: %s' % path)
|
||||
|
||||
basename = path.rsplit('/', 1)[-1]
|
||||
self.write(
|
||||
self.render_template('view.html', file_path=url_escape(path), page_title=basename)
|
||||
)
|
||||
|
||||
default_handlers = [
|
||||
(r"/view%s" % path_regex, ViewHandler),
|
||||
]
|
||||
Loading…
Reference in new issue