Update app directory structure, add home and routes
This commit is contained in:
0
atst/__init__.py
Normal file
0
atst/__init__.py
Normal file
13
atst/app.py
Normal file
13
atst/app.py
Normal file
@@ -0,0 +1,13 @@
|
||||
import tornado.web
|
||||
from atst.handlers.main import MainHandler
|
||||
from atst.home import home
|
||||
|
||||
def make_app(**kwargs):
|
||||
app = tornado.web.Application([
|
||||
(r"/", MainHandler),
|
||||
],
|
||||
template_path = home.child('templates'),
|
||||
static_path = home.child('static'),
|
||||
**kwargs
|
||||
)
|
||||
return app
|
||||
24
atst/handler.py
Normal file
24
atst/handler.py
Normal file
@@ -0,0 +1,24 @@
|
||||
import os
|
||||
from webassets import Environment, Bundle
|
||||
import tornado.web
|
||||
from atst.home import home
|
||||
|
||||
class BaseHandler(tornado.web.RequestHandler):
|
||||
|
||||
def get_template_namespace(self):
|
||||
assets = Environment(
|
||||
directory = home.child('scss'),
|
||||
url = '/static')
|
||||
css = Bundle(
|
||||
'atat.scss',
|
||||
filters = 'scss',
|
||||
output = '../static/assets/out.css')
|
||||
|
||||
assets.register( 'css', css )
|
||||
helpers = {
|
||||
'assets': assets
|
||||
}
|
||||
|
||||
ns = super(BaseHandler, self).get_template_namespace()
|
||||
ns.update(helpers)
|
||||
return ns
|
||||
0
atst/handlers/__init__.py
Normal file
0
atst/handlers/__init__.py
Normal file
5
atst/handlers/main.py
Normal file
5
atst/handlers/main.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from atst.handler import BaseHandler
|
||||
|
||||
class MainHandler(BaseHandler):
|
||||
def get(self):
|
||||
self.render("hello.html.to")
|
||||
3
atst/home.py
Normal file
3
atst/home.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from unipath import Path
|
||||
|
||||
home = Path( __file__ ).parent.parent
|
||||
Reference in New Issue
Block a user