Hello, world

This commit is contained in:
Brian Duggan 2018-05-22 13:37:51 -04:00
parent 6349f7e60e
commit 29248ed76e
4 changed files with 59 additions and 0 deletions

View File

@ -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

22
app.py Executable file
View File

@ -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()

14
templates/base.html.to Normal file
View File

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<title>{% block title %}your title here{% end %}</title>
</head>
<h1>{% block title %}your title here again{% end %}</h1>
<body>
<ul>
{% block content %}
your content goes here
{% end %}
</ul>
</body>
</html>

10
templates/hello.html.to Normal file
View File

@ -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 %}