|
@@ -1,19 +1,20 @@
|
|
|
#!/usr/bin/env python3
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import json
|
|
import json
|
|
|
-from lesscss import lessc
|
|
|
|
|
|
|
+import operator
|
|
|
|
|
+import os
|
|
|
|
|
+
|
|
|
|
|
+import cleancss
|
|
|
import tornado.gen
|
|
import tornado.gen
|
|
|
import tornado.httpclient
|
|
import tornado.httpclient
|
|
|
import tornado.ioloop
|
|
import tornado.ioloop
|
|
|
import tornado.web
|
|
import tornado.web
|
|
|
-import operator
|
|
|
|
|
-import os
|
|
|
|
|
|
|
|
|
|
-import config
|
|
|
|
|
|
|
+from config import web as config
|
|
|
|
|
|
|
|
class BaseHandler(tornado.web.RequestHandler):
|
|
class BaseHandler(tornado.web.RequestHandler):
|
|
|
def render(self, *args, **kwargs):
|
|
def render(self, *args, **kwargs):
|
|
|
- kwargs['host'] = config.web.host
|
|
|
|
|
|
|
+ kwargs['host'] = config.host
|
|
|
return super(BaseHandler, self).render(*args, **kwargs)
|
|
return super(BaseHandler, self).render(*args, **kwargs)
|
|
|
|
|
|
|
|
def render_string(self, *args, **kwargs):
|
|
def render_string(self, *args, **kwargs):
|
|
@@ -36,11 +37,11 @@ class MainHandler(BaseHandler):
|
|
|
|
|
|
|
|
class CSSHandler(tornado.web.RequestHandler):
|
|
class CSSHandler(tornado.web.RequestHandler):
|
|
|
def get(self, css_path):
|
|
def get(self, css_path):
|
|
|
- css_path = os.path.join(os.path.dirname(__file__), 'static', css_path) + '.less'
|
|
|
|
|
|
|
+ css_path = os.path.join(os.path.dirname(__file__), 'web', 'static', css_path) + '.ccss'
|
|
|
with open(css_path, 'r') as f:
|
|
with open(css_path, 'r') as f:
|
|
|
self.set_header('Content-Type', 'text/css')
|
|
self.set_header('Content-Type', 'text/css')
|
|
|
- css = lessc.compile(f.read())
|
|
|
|
|
- self.write(css)
|
|
|
|
|
|
|
+ self.write(cleancss.convert(f))
|
|
|
|
|
+
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
if __name__ == '__main__':
|
|
|
tornado.web.Application(
|
|
tornado.web.Application(
|
|
@@ -50,8 +51,8 @@ if __name__ == '__main__':
|
|
|
],
|
|
],
|
|
|
template_path=os.path.join(os.path.dirname(__file__), 'templates'),
|
|
template_path=os.path.join(os.path.dirname(__file__), 'templates'),
|
|
|
static_path=os.path.join(os.path.dirname(__file__), 'static'),
|
|
static_path=os.path.join(os.path.dirname(__file__), 'static'),
|
|
|
- cookie_secret=config.web.cookie_secret,
|
|
|
|
|
- debug=True,
|
|
|
|
|
- ).listen(config.web.port)
|
|
|
|
|
- print('Listening on :%d' % config.web.port)
|
|
|
|
|
|
|
+ cookie_secret=config.cookie_secret,
|
|
|
|
|
+ debug=config.debug,
|
|
|
|
|
+ ).listen(config.port)
|
|
|
|
|
+ print('listening on :%d' % config.port)
|
|
|
tornado.ioloop.IOLoop.instance().start()
|
|
tornado.ioloop.IOLoop.instance().start()
|