From 29248ed76e9d1f20860f16d6a0dc450bc24d336a Mon Sep 17 00:00:00 2001 From: Brian Duggan Date: Tue, 22 May 2018 13:37:51 -0400 Subject: [PATCH] Hello, world --- README.md | 13 +++++++++++++ app.py | 22 ++++++++++++++++++++++ templates/base.html.to | 14 ++++++++++++++ templates/hello.html.to | 10 ++++++++++ 4 files changed, 59 insertions(+) create mode 100755 app.py create mode 100644 templates/base.html.to create mode 100644 templates/hello.html.to diff --git a/README.md b/README.md index 33986703..18e8a364 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,21 @@ # ATST ## Installation + brew install python3 python3 -m venv .venv . .venv/bin/activate pip install --upgrade pip pip install -r requirements.txt + +## Running (development) + + DEBUG=1 ./app.py + +## Notes + +tornado templates are like mustache templates -- add the +following to `~/.vim/filetype.vim` for syntax highlighting: + + :au BufRead *.html.to set filetype=mustache + diff --git a/app.py b/app.py new file mode 100755 index 00000000..8194ea46 --- /dev/null +++ b/app.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python + +import tornado.ioloop +import tornado.web +import os + +class MainHandler(tornado.web.RequestHandler): + def get(self): + self.render("hello.html.to") + +def make_app(): + return tornado.web.Application([ + (r"/", MainHandler), + ], + template_path='./templates', + debug=os.getenv('DEBUG',False), + ) + +if __name__ == "__main__": + app = make_app() + app.listen(8888) + tornado.ioloop.IOLoop.current().start() diff --git a/templates/base.html.to b/templates/base.html.to new file mode 100644 index 00000000..cfa4c9a2 --- /dev/null +++ b/templates/base.html.to @@ -0,0 +1,14 @@ + + + + {% block title %}your title here{% end %} + +

{% block title %}your title here again{% end %}

+ + + + diff --git a/templates/hello.html.to b/templates/hello.html.to new file mode 100644 index 00000000..eb4cb96f --- /dev/null +++ b/templates/hello.html.to @@ -0,0 +1,10 @@ +{% extends "base.html.to" %} + +{% block title %} +this is an amazing title for hello +{% end %} + +{% block content %} +This is more content for hello +{% end %} +