add basic templates
This commit is contained in:
parent
6a1b632dcb
commit
84cdfac30d
6 changed files with 31 additions and 7 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,7 +2,6 @@
|
|||
node_modules/
|
||||
storage/
|
||||
__pycache__
|
||||
dist/
|
||||
npm-debug*.log
|
||||
ssl/*.pem
|
||||
*.py[cod]
|
||||
|
|
13
diffido.py
13
diffido.py
|
@ -86,15 +86,16 @@ class BaseHandler(tornado.web.RequestHandler):
|
|||
self.write({'error': True, 'message': message})
|
||||
|
||||
|
||||
class RootHandler(BaseHandler):
|
||||
class TemplateHandler(BaseHandler):
|
||||
"""Handler for the / path."""
|
||||
app_path = os.path.join(os.path.dirname(__file__), "dist")
|
||||
|
||||
@gen.coroutine
|
||||
def get(self, *args, **kwargs):
|
||||
# serve the ./dist/index.html file
|
||||
with open(self.app_path + "/index.html", 'r') as fd:
|
||||
self.write(fd.read())
|
||||
page = 'index.html'
|
||||
if args and args[0]:
|
||||
page = args[0].strip('/')
|
||||
self.render(page, **self.arguments)
|
||||
|
||||
|
||||
def serve():
|
||||
|
@ -128,10 +129,10 @@ def serve():
|
|||
application = tornado.web.Application([
|
||||
# (_days_path, DaysHandler, init_params),
|
||||
# (r'/v%s%s' % (API_VERSION, _days_path), DaysHandler, init_params),
|
||||
(r"/(?:index.html)?", RootHandler, init_params),
|
||||
(r'/?(.*)', tornado.web.StaticFileHandler, {"path": "dist"})
|
||||
(r"/?(.*)", TemplateHandler, init_params),
|
||||
],
|
||||
static_path=os.path.join(os.path.dirname(__file__), "dist/static"),
|
||||
template_path=os.path.join(os.path.dirname(__file__), 'dist/'),
|
||||
debug=options.debug)
|
||||
http_server = tornado.httpserver.HTTPServer(application, ssl_options=ssl_options or None)
|
||||
logger.info('Start serving on %s://%s:%d', 'https' if ssl_options else 'http',
|
||||
|
|
8
dist/base.html
vendored
Normal file
8
dist/base.html
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>{% block title %}diffido{% end %}</title>
|
||||
</head>
|
||||
<body>
|
||||
{% block body %}{% end %}
|
||||
</body>
|
||||
</html>
|
5
dist/diff.html
vendored
Normal file
5
dist/diff.html
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block body %}
|
||||
diff page {{ id }}
|
||||
{% end %}
|
6
dist/index.html
vendored
Normal file
6
dist/index.html
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block body %}
|
||||
Index
|
||||
<a href="/page.html/?id=3">setting 3</a>; <a href="/diff.html?id=3">diff 3</a>
|
||||
{% end %}
|
5
dist/page.html
vendored
Normal file
5
dist/page.html
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block body %}
|
||||
setting page {{ id }}
|
||||
{% end %}
|
Loading…
Reference in a new issue