def main(): config = web.Config('liege-web') config.option('wit-token', type=str) config.retrieve() # where we send wit messages to if config.debug: print "Binding ZeroMQ at: " + str([squidwork.quick.resolve_hostname(u) for u in config.uris]) socket = squidwork.quick.pub(*config.uris) handlers = web.handlers(config.raw_config, debug=config.debug) handlers += [ (r'/', web.TemplateRenderer, dict(source='index.html')), (r'/wit', WitQueryHandler, dict(socket=socket, wit_token=config.wit_token)), (r'/app.js', web.CoffeescriptHandler, dict(source='app.coffee')), (r'/style.css', ScssHandler, dict(source='style.scss')), (r'/services.json', web.JSONHandler, dict(data=uris_for_prefixes)) ] templates = os.path.dirname(os.path.realpath(__file__)) + '/templates' app = tornado.web.Application(handlers, debug=config.debug, template_path=templates) try: app.listen(config.port) tornado.ioloop.IOLoop.instance().start() except KeyboardInterrupt: print ' keyboard interrupt: exiting.'
def main(): config = web.Config('liege-web') config.option('wit-token', type=str) config.retrieve() # where we send wit messages to if config.debug: print "Binding ZeroMQ at: " + str( [squidwork.quick.resolve_hostname(u) for u in config.uris]) socket = squidwork.quick.pub(*config.uris) handlers = web.handlers(config.raw_config, debug=config.debug) handlers += [ (r'/', web.TemplateRenderer, dict(source='index.html')), (r'/wit', WitQueryHandler, dict(socket=socket, wit_token=config.wit_token)), (r'/app.js', web.CoffeescriptHandler, dict(source='app.coffee')), (r'/style.css', ScssHandler, dict(source='style.scss')), (r'/services.json', web.JSONHandler, dict(data=uris_for_prefixes)) ] templates = os.path.dirname(os.path.realpath(__file__)) + '/templates' app = tornado.web.Application(handlers, debug=config.debug, template_path=templates) try: app.listen(config.port) tornado.ioloop.IOLoop.instance().start() except KeyboardInterrupt: print ' keyboard interrupt: exiting.'
def main(): # options config = configure() handlers = web.handlers(config.raw_config, debug=config.debug) handlers += [ (r'/upload.exe', CanUpload, dict(debug=config.debug, root=config.images + '/uploads')), (r'/auth.exe', AuthHandler, dict(secret=config.password, debug=config.debug)), (r'/app.js', web.CoffeescriptHandler, dict(source='app.coffee')), (r'/style.css', ScssHandler, dict(source='style.scss')), (r'/thumbs/(.*)', tornado.web.StaticFileHandler, dict(path=config.thumbs)), (r'/files/(.*)', HitCountImageServer, dict(path=config.images)), (r'/(.*)', DirectoryLister, dict(debug=config.debug, path=config.images)) ] home = os.path.dirname(os.path.realpath(__file__)) static = home + '/static' templates = home + '/templates' if config.debug: app_class = debuggable.DebugApplication else: app_class = tornado.web.Application app = app_class(handlers, debug=config.debug, template_path=templates, static_path=static, cookie_secret=config.app_secret) try: print('Listening on {}'.format(config.port)) app.listen(config.port) tornado.ioloop.IOLoop.instance().start() except KeyboardInterrupt: print ' keyboard interrupt: exiting.'