Better asset handling
This commit is contained in:
22
app.py
22
app.py
@@ -3,19 +3,37 @@
|
||||
import tornado.ioloop
|
||||
import tornado.web
|
||||
import os
|
||||
from webassets import Environment, Bundle
|
||||
|
||||
# Set up assets.
|
||||
static_path = os.path.join(os.path.dirname(__file__), "static")
|
||||
scss_path = os.path.join(os.path.dirname(__file__), "scss")
|
||||
assets = Environment(directory=scss_path, url='/static')
|
||||
css = Bundle('atat.scss', output='assets/out.css')
|
||||
assets.register('css', css)
|
||||
helpers = {
|
||||
'assets': assets
|
||||
}
|
||||
|
||||
class MainHandler(tornado.web.RequestHandler):
|
||||
|
||||
def get_template_namespace(self):
|
||||
ns = super(MainHandler, self).get_template_namespace()
|
||||
ns.update(helpers)
|
||||
return ns
|
||||
|
||||
def get(self):
|
||||
self.render("hello.html.to")
|
||||
|
||||
def make_app():
|
||||
return tornado.web.Application([
|
||||
app = tornado.web.Application([
|
||||
(r"/", MainHandler),
|
||||
],
|
||||
debug=os.getenv('DEBUG',False),
|
||||
template_path=os.path.join(os.path.dirname(__file__), "templates"),
|
||||
static_path=os.path.join(os.path.dirname(__file__), "static"),
|
||||
static_path=static_path
|
||||
)
|
||||
return app
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = make_app()
|
||||
|
Reference in New Issue
Block a user