# -*- coding: utf-8 -*-
'''
@author: moloch

    Copyright 2013

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
'''


import logging

from os import urandom
from tornado import netutil
from tornado.web import Application, StaticFileHandler
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
from uimodules.Menu import Menu
from libs.ConfigManager import ConfigManager
from handlers.PublicHandlers import *
from handlers.ErrorHandlers import *
from handlers.AdminHandlers import *
from handlers.UserHandlers import *
from handlers.MainHandlers import *

### Config
config = ConfigManager.instance()

### Application setup
app = Application([

    # Static Handlers - Serves static CSS, JS and images
    (r'/static/(.*\.(css|js|png|jpg|jpeg|svg|ttf|html))',
        StaticFileHandler, {'path': 'static/'}),

    (r'/', MainHandler),

    # User Handlers -
    (r'/user', UserHomeHandler),

    # Admin Handlers -

    # Error Handlers -
    (r'/403', ForbiddenHandler),

    # Catch all 404 page
    (r'(.*)', NotFoundHandler),

],

    # Randomly generated secret key
    cookie_secret=urandom(32).encode('hex'),

    # Request that does not pass @authorized will be
    # redirected here
    forbidden_url='/403',

    # Requests that does not pass @authenticated  will be
    # redirected here
    login_url='/login',

    # Template directory
    template_path='templates/',

    # UI Modules
    ui_modules={
        "menu": Menu,
    },

    # Enable XSRF forms
    xsrf_cookies=True,

    # Debug mode
    debug=config.debug,
)


def start_server():
    ''' Main entry point for the application '''
    sockets = netutil.bind_sockets(config.listen_port)
    if config.use_ssl:
        server = HTTPServer(app,
            ssl_options={
                "certfile": config.certfile,
                "keyfile": config.keyfile,
            },
            xheaders=config.x_headers)
    else:
        server = HTTPServer(app, xheaders=config.x_headers)
    server.add_sockets(sockets)
    io_loop = IOLoop.instance()
    try:
        io_loop.start()
    except KeyboardInterrupt:
        logging.warn("Keyboard interrupt, shutdown everything!")
    except:
        logging.exception("Main I/O Loop threw an excetion!")
    finally:
        io_loop.stop()
b4b95c6f56c6e86e11faf27b28253c417f06cafb
<mask token>

<mask token>


def start_server():
    """ Main entry point for the application """
    sockets = netutil.bind_sockets(config.listen_port)
    if config.use_ssl:
        server = HTTPServer(app, ssl_options={'certfile': config.certfile,
            'keyfile': config.keyfile}, xheaders=config.x_headers)
    else:
        server = HTTPServer(app, xheaders=config.x_headers)
    server.add_sockets(sockets)
    io_loop = IOLoop.instance()
    try:
        io_loop.start()
    except KeyboardInterrupt:
        logging.warn('Keyboard interrupt, shutdown everything!')
    except:
        logging.exception('Main I/O Loop threw an excetion!')
    finally:
        io_loop.stop()

<mask token>
config = ConfigManager.instance()
app = Application([('/static/(.*\\.(css|js|png|jpg|jpeg|svg|ttf|html))',
    StaticFileHandler, {'path': 'static/'}), ('/', MainHandler), ('/user',
    UserHomeHandler), ('/403', ForbiddenHandler), ('(.*)', NotFoundHandler)
    ], cookie_secret=urandom(32).encode('hex'), forbidden_url='/403',
    login_url='/login', template_path='templates/', ui_modules={'menu':
    Menu}, xsrf_cookies=True, debug=config.debug)


def start_server():
    """ Main entry point for the application """
    sockets = netutil.bind_sockets(config.listen_port)
    if config.use_ssl:
        server = HTTPServer(app, ssl_options={'certfile': config.certfile,
            'keyfile': config.keyfile}, xheaders=config.x_headers)
    else:
        server = HTTPServer(app, xheaders=config.x_headers)
    server.add_sockets(sockets)
    io_loop = IOLoop.instance()
    try:
        io_loop.start()
    except KeyboardInterrupt:
        logging.warn('Keyboard interrupt, shutdown everything!')
    except:
        logging.exception('Main I/O Loop threw an excetion!')
    finally:
        io_loop.stop()

<mask token>
import logging
from os import urandom
from tornado import netutil
from tornado.web import Application, StaticFileHandler
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
from uimodules.Menu import Menu
from libs.ConfigManager import ConfigManager
from handlers.PublicHandlers import *
from handlers.ErrorHandlers import *
from handlers.AdminHandlers import *
from handlers.UserHandlers import *
from handlers.MainHandlers import *
config = ConfigManager.instance()
app = Application([('/static/(.*\\.(css|js|png|jpg|jpeg|svg|ttf|html))',
    StaticFileHandler, {'path': 'static/'}), ('/', MainHandler), ('/user',
    UserHomeHandler), ('/403', ForbiddenHandler), ('(.*)', NotFoundHandler)
    ], cookie_secret=urandom(32).encode('hex'), forbidden_url='/403',
    login_url='/login', template_path='templates/', ui_modules={'menu':
    Menu}, xsrf_cookies=True, debug=config.debug)


def start_server():
    """ Main entry point for the application """
    sockets = netutil.bind_sockets(config.listen_port)
    if config.use_ssl:
        server = HTTPServer(app, ssl_options={'certfile': config.certfile,
            'keyfile': config.keyfile}, xheaders=config.x_headers)
    else:
        server = HTTPServer(app, xheaders=config.x_headers)
    server.add_sockets(sockets)
    io_loop = IOLoop.instance()
    try:
        io_loop.start()
    except KeyboardInterrupt:
        logging.warn('Keyboard interrupt, shutdown everything!')
    except:
        logging.exception('Main I/O Loop threw an excetion!')
    finally:
        io_loop.stop()

# -*- coding: utf-8 -*-
'''
@author: moloch

    Copyright 2013

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
'''


import logging

from os import urandom
from tornado import netutil
from tornado.web import Application, StaticFileHandler
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
from uimodules.Menu import Menu
from libs.ConfigManager import ConfigManager
from handlers.PublicHandlers import *
from handlers.ErrorHandlers import *
from handlers.AdminHandlers import *
from handlers.UserHandlers import *
from handlers.MainHandlers import *

### Config
config = ConfigManager.instance()

### Application setup
app = Application([

    # Static Handlers - Serves static CSS, JS and images
    (r'/static/(.*\.(css|js|png|jpg|jpeg|svg|ttf|html))',
        StaticFileHandler, {'path': 'static/'}),

    (r'/', MainHandler),

    # User Handlers -
    (r'/user', UserHomeHandler),

    # Admin Handlers -

    # Error Handlers -
    (r'/403', ForbiddenHandler),

    # Catch all 404 page
    (r'(.*)', NotFoundHandler),

],

    # Randomly generated secret key
    cookie_secret=urandom(32).encode('hex'),

    # Request that does not pass @authorized will be
    # redirected here
    forbidden_url='/403',

    # Requests that does not pass @authenticated  will be
    # redirected here
    login_url='/login',

    # Template directory
    template_path='templates/',

    # UI Modules
    ui_modules={
        "menu": Menu,
    },

    # Enable XSRF forms
    xsrf_cookies=True,

    # Debug mode
    debug=config.debug,
)


def start_server():
    ''' Main entry point for the application '''
    sockets = netutil.bind_sockets(config.listen_port)
    if config.use_ssl:
        server = HTTPServer(app,
            ssl_options={
                "certfile": config.certfile,
                "keyfile": config.keyfile,
            },
            xheaders=config.x_headers)
    else:
        server = HTTPServer(app, xheaders=config.x_headers)
    server.add_sockets(sockets)
    io_loop = IOLoop.instance()
    try:
        io_loop.start()
    except KeyboardInterrupt:
        logging.warn("Keyboard interrupt, shutdown everything!")
    except:
        logging.exception("Main I/O Loop threw an excetion!")
    finally:
        io_loop.stop()