예제 #1
0
    def start(self):
        self.started = True

        # video root
        self.video_root = None
        if sickrage.srCore.srConfig.ROOT_DIRS:
            root_dirs = sickrage.srCore.srConfig.ROOT_DIRS.split('|')
            self.video_root = root_dirs[int(root_dirs[0]) + 1]

        # web root
        if sickrage.srCore.srConfig.WEB_ROOT:
            sickrage.srCore.srConfig.WEB_ROOT = sickrage.srCore.srConfig.WEB_ROOT = (
                '/' + sickrage.srCore.srConfig.WEB_ROOT.lstrip('/').strip('/'))

        # api root
        if not sickrage.srCore.srConfig.API_KEY:
            sickrage.srCore.srConfig.API_KEY = generateApiKey()
        self.api_root = r'%s/api/%s' % (sickrage.srCore.srConfig.WEB_ROOT,
                                        sickrage.srCore.srConfig.API_KEY)

        # tornado setup
        if sickrage.srCore.srConfig.ENABLE_HTTPS:
            # If either the HTTPS certificate or key do not exist, make some self-signed ones.
            if not (sickrage.srCore.srConfig.HTTPS_CERT and os.path.exists(
                    sickrage.srCore.srConfig.HTTPS_CERT)) or not (
                        sickrage.srCore.srConfig.HTTPS_KEY and os.path.exists(
                            sickrage.srCore.srConfig.HTTPS_KEY)):
                if not create_https_certificates(
                        sickrage.srCore.srConfig.HTTPS_CERT,
                        sickrage.srCore.srConfig.HTTPS_KEY):
                    sickrage.srCore.srLogger.info(
                        "Unable to create CERT/KEY files, disabling HTTPS")
                    sickrage.srCore.srConfig.ENABLE_HTTPS = False

            if not (os.path.exists(sickrage.srCore.srConfig.HTTPS_CERT)
                    and os.path.exists(sickrage.srCore.srConfig.HTTPS_KEY)):
                sickrage.srCore.srLogger.warning(
                    "Disabled HTTPS because of missing CERT and KEY files")
                sickrage.srCore.srConfig.ENABLE_HTTPS = False

        # Load the app
        self.app = Application(
            [],
            debug=False,
            autoreload=False,
            gzip=sickrage.srCore.srConfig.WEB_USE_GZIP,
            xheaders=sickrage.srCore.srConfig.HANDLE_REVERSE_PROXY,
            cookie_secret=sickrage.srCore.srConfig.WEB_COOKIE_SECRET,
            login_url='%s/login/' % sickrage.srCore.srConfig.WEB_ROOT)

        # Main Handlers
        self.app.add_handlers(
            '.*$',
            [
                # webapi handler
                (r'%s(/?.*)' % self.api_root, ApiHandler),

                # webapi key retrieval
                (r'%s/getkey(/?.*)' % sickrage.srCore.srConfig.WEB_ROOT,
                 KeyHandler),

                # webapi builder redirect
                (r'%s/api/builder' % sickrage.srCore.srConfig.WEB_ROOT,
                 RedirectHandler, {
                     "url": sickrage.srCore.srConfig.WEB_ROOT + '/apibuilder/'
                 }),

                # webui login/logout handlers
                (r'%s/login(/?)' % sickrage.srCore.srConfig.WEB_ROOT,
                 LoginHandler),
                (r'%s/logout(/?)' % sickrage.srCore.srConfig.WEB_ROOT,
                 LogoutHandler),

                # webui handlers
            ] + Route.get_routes(sickrage.srCore.srConfig.WEB_ROOT))

        # Web calendar handler (Needed because option Unprotected calendar)
        self.app.add_handlers('.*$', [
            (r'%s/calendar' % sickrage.srCore.srConfig.WEB_ROOT,
             CalendarHandler),
        ])

        # Static File Handlers
        self.app.add_handlers(
            ".*$",
            [
                # favicon
                (r'%s/(favicon\.ico)' % sickrage.srCore.srConfig.WEB_ROOT,
                 StaticFileHandler, {
                     "path":
                     os.path.join(sickrage.srCore.srConfig.GUI_DIR,
                                  'images/ico/favicon.ico')
                 }),

                # images
                (r'%s.*?/images/(.*)' % sickrage.srCore.srConfig.WEB_ROOT,
                 StaticImageHandler, {
                     "path":
                     os.path.join(sickrage.srCore.srConfig.GUI_DIR, 'images')
                 }),

                # css
                (r'%s/css/(.*)' % sickrage.srCore.srConfig.WEB_ROOT,
                 StaticFileHandler, {
                     "path": os.path.join(sickrage.srCore.srConfig.GUI_DIR,
                                          'css')
                 }),

                # scss
                (r'%s/scss/(.*)' % sickrage.srCore.srConfig.WEB_ROOT,
                 StaticFileHandler, {
                     "path": os.path.join(sickrage.srCore.srConfig.GUI_DIR,
                                          'scss')
                 }),

                # fonts
                (r'%s/fonts/(.*)' % sickrage.srCore.srConfig.WEB_ROOT,
                 StaticFileHandler, {
                     "path":
                     os.path.join(sickrage.srCore.srConfig.GUI_DIR, 'fonts')
                 }),

                # javascript
                (r'%s/js/(.*)' % sickrage.srCore.srConfig.WEB_ROOT,
                 StaticFileHandler, {
                     "path": os.path.join(sickrage.srCore.srConfig.GUI_DIR,
                                          'js')
                 }),

                # videos
            ] + [(r'%s/videos/(.*)' % sickrage.srCore.srConfig.WEB_ROOT,
                  StaticFileHandler, {
                      "path": self.video_root
                  })])

        self.server = HTTPServer(self.app, no_keep_alive=True)

        if sickrage.srCore.srConfig.ENABLE_HTTPS:
            self.server.ssl_options = {
                "certfile": sickrage.srCore.srConfig.HTTPS_CERT,
                "keyfile": sickrage.srCore.srConfig.HTTPS_KEY
            }

        try:
            self.server.listen(sickrage.srCore.srConfig.WEB_PORT, None)
        except socket.error as e:
            print(e.message)
            raise

        # launch browser window
        if all(
            [not sickrage.NOLAUNCH, sickrage.srCore.srConfig.LAUNCH_BROWSER]):
            threading.Thread(
                None, lambda: launch_browser(
                    ('http', 'https')[sickrage.srCore.srConfig.ENABLE_HTTPS],
                    get_lan_ip(), sickrage.srCore.srConfig.WEB_PORT)).start()

        # clear mako cache folder
        makocache = os.path.join(sickrage.srCore.srConfig.CACHE_DIR, 'mako')
        if os.path.isdir(makocache):
            shutil.rmtree(makocache)

        sickrage.srCore.srLogger.info("SiCKRAGE :: STARTED")
        sickrage.srCore.srLogger.info("SiCKRAGE :: VERSION:[{}]".format(
            sickrage.srCore.VERSIONUPDATER.updater.version))
        sickrage.srCore.srLogger.info("SiCKRAGE :: CONFIG:[{}]".format(
            sickrage.CONFIG_FILE))
        sickrage.srCore.srLogger.info("SiCKRAGE :: URL:[{}://{}:{}/]".format(
            ('http', 'https')[sickrage.srCore.srConfig.ENABLE_HTTPS],
            get_lan_ip(), sickrage.srCore.srConfig.WEB_PORT))
예제 #2
0
    def start(self):
        self.started = True

        # clear mako cache folder
        mako_cache = os.path.join(sickrage.CACHE_DIR, 'mako')
        if os.path.isdir(mako_cache):
            shutil.rmtree(mako_cache)

        # video root
        if sickrage.srCore.srConfig.ROOT_DIRS:
            root_dirs = sickrage.srCore.srConfig.ROOT_DIRS.split('|')
            self.video_root = root_dirs[int(root_dirs[0]) + 1]

        # web root
        if sickrage.srCore.srConfig.WEB_ROOT:
            sickrage.srCore.srConfig.WEB_ROOT = sickrage.srCore.srConfig.WEB_ROOT = (
                '/' + sickrage.srCore.srConfig.WEB_ROOT.lstrip('/').strip('/'))

        # api root
        if not sickrage.srCore.srConfig.API_KEY:
            sickrage.srCore.srConfig.API_KEY = generateApiKey()
        self.api_root = r'%s/api/%s' % (sickrage.srCore.srConfig.WEB_ROOT,
                                        sickrage.srCore.srConfig.API_KEY)

        # tornado setup
        if sickrage.srCore.srConfig.ENABLE_HTTPS:
            # If either the HTTPS certificate or key do not exist, make some self-signed ones.
            if not (sickrage.srCore.srConfig.HTTPS_CERT and os.path.exists(
                    sickrage.srCore.srConfig.HTTPS_CERT)) or not (
                        sickrage.srCore.srConfig.HTTPS_KEY and os.path.exists(
                            sickrage.srCore.srConfig.HTTPS_KEY)):
                if not create_https_certificates(
                        sickrage.srCore.srConfig.HTTPS_CERT,
                        sickrage.srCore.srConfig.HTTPS_KEY):
                    sickrage.srCore.srLogger.info(
                        "Unable to create CERT/KEY files, disabling HTTPS")
                    sickrage.srCore.srConfig.ENABLE_HTTPS = False

            if not (os.path.exists(sickrage.srCore.srConfig.HTTPS_CERT)
                    and os.path.exists(sickrage.srCore.srConfig.HTTPS_KEY)):
                sickrage.srCore.srLogger.warning(
                    "Disabled HTTPS because of missing CERT and KEY files")
                sickrage.srCore.srConfig.ENABLE_HTTPS = False

        # Load the app
        self.app = Application(
            [
                # api
                (r'%s(/?.*)' % self.api_root, ApiHandler),

                # api key
                (r'%s/getkey(/?.*)' % sickrage.srCore.srConfig.WEB_ROOT,
                 KeyHandler),

                # api builder
                (r'%s/api/builder' % sickrage.srCore.srConfig.WEB_ROOT,
                 RedirectHandler, {
                     "url": sickrage.srCore.srConfig.WEB_ROOT + '/apibuilder/'
                 }),

                # login
                (r'%s/login(/?)' % sickrage.srCore.srConfig.WEB_ROOT,
                 LoginHandler),

                # logout
                (r'%s/logout(/?)' % sickrage.srCore.srConfig.WEB_ROOT,
                 LogoutHandler),

                # calendar
                (r'%s/calendar' % sickrage.srCore.srConfig.WEB_ROOT,
                 CalendarHandler),

                # favicon
                (r'%s/(favicon\.ico)' % sickrage.srCore.srConfig.WEB_ROOT,
                 StaticFileHandler, {
                     "path":
                     os.path.join(sickrage.srCore.srConfig.GUI_DIR,
                                  'images/ico/favicon.ico')
                 }),

                # images
                (r'%s/images/(.*)' % sickrage.srCore.srConfig.WEB_ROOT,
                 StaticImageHandler, {
                     "path":
                     os.path.join(sickrage.srCore.srConfig.GUI_DIR, 'images')
                 }),

                # css
                (r'%s/css/(.*)' % sickrage.srCore.srConfig.WEB_ROOT,
                 StaticFileHandler, {
                     "path": os.path.join(sickrage.srCore.srConfig.GUI_DIR,
                                          'css')
                 }),

                # scss
                (r'%s/scss/(.*)' % sickrage.srCore.srConfig.WEB_ROOT,
                 StaticFileHandler, {
                     "path": os.path.join(sickrage.srCore.srConfig.GUI_DIR,
                                          'scss')
                 }),

                # fonts
                (r'%s/fonts/(.*)' % sickrage.srCore.srConfig.WEB_ROOT,
                 StaticFileHandler, {
                     "path":
                     os.path.join(sickrage.srCore.srConfig.GUI_DIR, 'fonts')
                 }),

                # javascript
                (r'%s/js/(.*)' % sickrage.srCore.srConfig.WEB_ROOT,
                 StaticFileHandler, {
                     "path": os.path.join(sickrage.srCore.srConfig.GUI_DIR,
                                          'js')
                 }),

                # videos
                (r'%s/videos/(.*)' % sickrage.srCore.srConfig.WEB_ROOT,
                 StaticFileHandler, {
                     "path": self.video_root
                 }),
            ] + Route.get_routes(sickrage.srCore.srConfig.WEB_ROOT),
            debug=sickrage.DEBUG,
            autoreload=False,
            gzip=sickrage.srCore.srConfig.WEB_USE_GZIP,
            xheaders=sickrage.srCore.srConfig.HANDLE_REVERSE_PROXY,
            cookie_secret=sickrage.srCore.srConfig.WEB_COOKIE_SECRET,
            login_url='%s/login/' % sickrage.srCore.srConfig.WEB_ROOT)

        self.server = HTTPServer(self.app, no_keep_alive=True)

        if sickrage.srCore.srConfig.ENABLE_HTTPS:
            self.server.ssl_options = {
                "certfile": sickrage.srCore.srConfig.HTTPS_CERT,
                "keyfile": sickrage.srCore.srConfig.HTTPS_KEY
            }

        try:
            self.server.listen(sickrage.srCore.srConfig.WEB_PORT, None)
        except socket.error as e:
            print(e.message)
            raise
예제 #3
0
    def __init__(self, **kwargs):
        self.running = True
        self.restart = False
        self.io_loop = IOLoop.instance()

        self.options = {}
        self.options.setdefault('port', 8081)
        self.options.setdefault('host', '0.0.0.0')
        self.options.setdefault('log_dir', None)
        self.options.setdefault('username', '')
        self.options.setdefault('password', '')
        self.options.setdefault('web_root', '/')
        self.options.setdefault('stop_timeout', 3)
        self.options.update(kwargs)

        # video root
        if sickrage.ROOT_DIRS:
            root_dirs = sickrage.ROOT_DIRS.split('|')
            self.video_root = root_dirs[int(root_dirs[0]) + 1]
        else:
            self.video_root = None

        # web root
        if self.options[b'web_root']:
            sickrage.WEB_ROOT = self.options[b'web_root'] = (
                '/' + self.options[b'web_root'].lstrip('/').strip('/'))

        # api root
        if not sickrage.API_KEY:
            sickrage.API_KEY = generateApiKey()
        self.options[b'api_root'] = r'%s/api/%s' % (sickrage.WEB_ROOT,
                                                    sickrage.API_KEY)

        # tornado setup
        self.enable_https = self.options[b'enable_https']
        self.https_cert = self.options[b'https_cert']
        self.https_key = self.options[b'https_key']

        if self.enable_https:
            # If either the HTTPS certificate or key do not exist, make some self-signed ones.
            if not (self.https_cert
                    and os.path.exists(self.https_cert)) or not (
                        self.https_key and os.path.exists(self.https_key)):
                if not create_https_certificates(self.https_cert,
                                                 self.https_key):
                    sickrage.LOGGER.info(
                        "Unable to create CERT/KEY files, disabling HTTPS")
                    sickrage.ENABLE_HTTPS = False
                    self.enable_https = False

            if not (os.path.exists(self.https_cert)
                    and os.path.exists(self.https_key)):
                sickrage.LOGGER.warning(
                    "Disabled HTTPS because of missing CERT and KEY files")
                sickrage.ENABLE_HTTPS = False
                self.enable_https = False

        # Load the app
        self.app = Application(
            [],
            debug=sickrage.DEBUG,
            autoreload=False,
            gzip=sickrage.WEB_USE_GZIP,
            xheaders=sickrage.HANDLE_REVERSE_PROXY,
            cookie_secret=sickrage.WEB_COOKIE_SECRET,
            login_url='%s/login/' % self.options[b'web_root'],
        )

        # Main Handlers
        self.app.add_handlers(
            '.*$',
            [
                # webapi handler
                (r'%s(/?.*)' % self.options[b'api_root'], ApiHandler),

                # webapi key retrieval
                (r'%s/getkey(/?.*)' % self.options[b'web_root'], KeyHandler),

                # webapi builder redirect
                (r'%s/api/builder' % self.options[b'web_root'],
                 RedirectHandler, {
                     "url": self.options[b'web_root'] + '/apibuilder/'
                 }),

                # webui login/logout handlers
                (r'%s/login(/?)' % self.options[b'web_root'], LoginHandler),
                (r'%s/logout(/?)' % self.options[b'web_root'], LogoutHandler),

                # webui handlers
            ] + route.get_routes(self.options[b'web_root']))

        # Web calendar handler (Needed because option Unprotected calendar)
        self.app.add_handlers('.*$', [
            (r'%s/calendar' % self.options[b'web_root'], CalendarHandler),
        ])

        # Static File Handlers
        self.app.add_handlers(
            ".*$",
            [
                # favicon
                (r'%s/(favicon\.ico)' % self.options[b'web_root'],
                 StaticFileHandler, {
                     "path":
                     os.path.join(self.options[b'gui_root'],
                                  'images/ico/favicon.ico')
                 }),

                # images
                (r'%s.*?/images/(.*)' % self.options[b'web_root'],
                 StaticImageHandler, {
                     "path": os.path.join(self.options[b'gui_root'], 'images')
                 }),

                # css
                (r'%s/css/(.*)' % self.options[b'web_root'], StaticFileHandler,
                 {
                     "path": os.path.join(self.options[b'gui_root'], 'css')
                 }),

                # javascript
                (r'%s/js/(.*)' % self.options[b'web_root'], StaticFileHandler,
                 {
                     "path": os.path.join(self.options[b'gui_root'], 'js')
                 }),

                # videos
            ] + [(r'%s/videos/(.*)' % self.options[b'web_root'],
                  StaticFileHandler, {
                      "path": self.video_root
                  })])

        # daemonize sickrage
        if sickrage.DAEMONIZE:
            import daemon
            ctx = daemon.DaemonContext()
            ctx.initgroups = False
            ctx.open()

        # write sickrage pidfile
        sickrage.PID = os.getpid()
        if sickrage.CREATEPID:
            with file(sickrage.PIDFILE, 'w+') as pf:
                pf.write(str(sickrage.PID))

        self.io_loop.add_callback(sickrage.Scheduler.start)
예제 #4
0
    def __init__(self, **kwargs):
        self.running = True
        self.restart = False
        self.io_loop = IOLoop.instance()

        self.options = {}
        self.options.setdefault('port', 8081)
        self.options.setdefault('host', '0.0.0.0')
        self.options.setdefault('log_dir', None)
        self.options.setdefault('username', '')
        self.options.setdefault('password', '')
        self.options.setdefault('web_root', '/')
        self.options.setdefault('stop_timeout', 3)
        self.options.update(kwargs)

        # video root
        if sickrage.ROOT_DIRS:
            root_dirs = sickrage.ROOT_DIRS.split('|')
            self.video_root = root_dirs[int(root_dirs[0]) + 1]
        else:
            self.video_root = None

        # web root
        if self.options[b'web_root']:
            sickrage.WEB_ROOT = self.options[b'web_root'] = ('/' + self.options[b'web_root'].lstrip('/').strip('/'))

        # api root
        if not sickrage.API_KEY:
            sickrage.API_KEY = generateApiKey()
        self.options[b'api_root'] = r'%s/api/%s' % (sickrage.WEB_ROOT, sickrage.API_KEY)

        # tornado setup
        self.enable_https = self.options[b'enable_https']
        self.https_cert = self.options[b'https_cert']
        self.https_key = self.options[b'https_key']

        if self.enable_https:
            # If either the HTTPS certificate or key do not exist, make some self-signed ones.
            if not (self.https_cert and os.path.exists(self.https_cert)) or not (
                        self.https_key and os.path.exists(self.https_key)):
                if not create_https_certificates(self.https_cert, self.https_key):
                    sickrage.LOGGER.info("Unable to create CERT/KEY files, disabling HTTPS")
                    sickrage.ENABLE_HTTPS = False
                    self.enable_https = False

            if not (os.path.exists(self.https_cert) and os.path.exists(self.https_key)):
                sickrage.LOGGER.warning("Disabled HTTPS because of missing CERT and KEY files")
                sickrage.ENABLE_HTTPS = False
                self.enable_https = False

        # Load the app
        self.app = Application([],
                               debug=sickrage.DEBUG,
                               autoreload=False,
                               gzip=sickrage.WEB_USE_GZIP,
                               xheaders=sickrage.HANDLE_REVERSE_PROXY,
                               cookie_secret=sickrage.WEB_COOKIE_SECRET,
                               login_url='%s/login/' % self.options[b'web_root'],
                               )

        # Main Handlers
        self.app.add_handlers('.*$', [
            # webapi handler
            (r'%s(/?.*)' % self.options[b'api_root'], ApiHandler),

            # webapi key retrieval
            (r'%s/getkey(/?.*)' % self.options[b'web_root'], KeyHandler),

            # webapi builder redirect
            (r'%s/api/builder' % self.options[b'web_root'], RedirectHandler,
             {"url": self.options[b'web_root'] + '/apibuilder/'}),

            # webui login/logout handlers
            (r'%s/login(/?)' % self.options[b'web_root'], LoginHandler),
            (r'%s/logout(/?)' % self.options[b'web_root'], LogoutHandler),

            # webui handlers
        ] + route.get_routes(self.options[b'web_root']))

        # Web calendar handler (Needed because option Unprotected calendar)
        self.app.add_handlers('.*$', [
            (r'%s/calendar' % self.options[b'web_root'], CalendarHandler),
        ])

        # Static File Handlers
        self.app.add_handlers(".*$", [
            # favicon
            (r'%s/(favicon\.ico)' % self.options[b'web_root'], StaticFileHandler,
             {"path": os.path.join(self.options[b'gui_root'], 'images/ico/favicon.ico')}),

            # images
            (r'%s.*?/images/(.*)' % self.options[b'web_root'], StaticImageHandler,
             {"path": os.path.join(self.options[b'gui_root'], 'images')}),

            # css
            (r'%s/css/(.*)' % self.options[b'web_root'], StaticFileHandler,
             {"path": os.path.join(self.options[b'gui_root'], 'css')}),

            # javascript
            (r'%s/js/(.*)' % self.options[b'web_root'], StaticFileHandler,
             {"path": os.path.join(self.options[b'gui_root'], 'js')}),

            # videos
        ] + [(r'%s/videos/(.*)' % self.options[b'web_root'], StaticFileHandler,
              {"path": self.video_root})])

        # daemonize sickrage
        if sickrage.DAEMONIZE:
            import daemon
            ctx = daemon.DaemonContext()
            ctx.initgroups = False
            ctx.open()

        # write sickrage pidfile
        sickrage.PID = os.getpid()
        if sickrage.CREATEPID:
            with file(sickrage.PIDFILE, 'w+') as pf:
                pf.write(str(sickrage.PID))

        self.io_loop.add_callback(sickrage.Scheduler.start)
예제 #5
0
    def start(self):
        self.started = True

        # video root
        self.video_root = None
        if sickrage.srCore.srConfig.ROOT_DIRS:
            root_dirs = sickrage.srCore.srConfig.ROOT_DIRS.split('|')
            self.video_root = root_dirs[int(root_dirs[0]) + 1]

        # web root
        if sickrage.srCore.srConfig.WEB_ROOT:
            sickrage.srCore.srConfig.WEB_ROOT = sickrage.srCore.srConfig.WEB_ROOT = (
                '/' + sickrage.srCore.srConfig.WEB_ROOT.lstrip('/').strip('/'))

        # api root
        if not sickrage.srCore.srConfig.API_KEY:
            sickrage.srCore.srConfig.API_KEY = generateApiKey()
        self.api_root = r'%s/api/%s' % (sickrage.srCore.srConfig.WEB_ROOT, sickrage.srCore.srConfig.API_KEY)

        # tornado setup
        if sickrage.srCore.srConfig.ENABLE_HTTPS:
            # If either the HTTPS certificate or key do not exist, make some self-signed ones.
            if not (
                        sickrage.srCore.srConfig.HTTPS_CERT and os.path.exists(
                        sickrage.srCore.srConfig.HTTPS_CERT)) or not (
                        sickrage.srCore.srConfig.HTTPS_KEY and os.path.exists(sickrage.srCore.srConfig.HTTPS_KEY)):
                if not create_https_certificates(sickrage.srCore.srConfig.HTTPS_CERT,
                                                 sickrage.srCore.srConfig.HTTPS_KEY):
                    sickrage.srCore.srLogger.info("Unable to create CERT/KEY files, disabling HTTPS")
                    sickrage.srCore.srConfig.ENABLE_HTTPS = False

            if not (os.path.exists(sickrage.srCore.srConfig.HTTPS_CERT) and os.path.exists(
                    sickrage.srCore.srConfig.HTTPS_KEY)):
                sickrage.srCore.srLogger.warning("Disabled HTTPS because of missing CERT and KEY files")
                sickrage.srCore.srConfig.ENABLE_HTTPS = False

        # Load the app
        self.app = Application([],
                               debug=False,
                               autoreload=False,
                               gzip=sickrage.srCore.srConfig.WEB_USE_GZIP,
                               xheaders=sickrage.srCore.srConfig.HANDLE_REVERSE_PROXY,
                               cookie_secret=sickrage.srCore.srConfig.WEB_COOKIE_SECRET,
                               login_url='%s/login/' % sickrage.srCore.srConfig.WEB_ROOT)

        # Main Handlers
        self.app.add_handlers('.*$', [
            # webapi handler
            (r'%s(/?.*)' % self.api_root, ApiHandler),

            # webapi key retrieval
            (r'%s/getkey(/?.*)' % sickrage.srCore.srConfig.WEB_ROOT, KeyHandler),

            # webapi builder redirect
            (r'%s/api/builder' % sickrage.srCore.srConfig.WEB_ROOT, RedirectHandler,
             {"url": sickrage.srCore.srConfig.WEB_ROOT + '/apibuilder/'}),

            # webui login/logout handlers
            (r'%s/login(/?)' % sickrage.srCore.srConfig.WEB_ROOT, LoginHandler),
            (r'%s/logout(/?)' % sickrage.srCore.srConfig.WEB_ROOT, LogoutHandler),

            # webui handlers
        ] + Route.get_routes(sickrage.srCore.srConfig.WEB_ROOT))

        # Web calendar handler (Needed because option Unprotected calendar)
        self.app.add_handlers('.*$', [
            (r'%s/calendar' % sickrage.srCore.srConfig.WEB_ROOT, CalendarHandler),
        ])

        # Static File Handlers
        self.app.add_handlers(".*$", [
            # favicon
            (r'%s/(favicon\.ico)' % sickrage.srCore.srConfig.WEB_ROOT, StaticFileHandler,
             {"path": os.path.join(sickrage.srCore.srConfig.GUI_DIR, 'images/ico/favicon.ico')}),

            # images
            (r'%s.*?/images/(.*)' % sickrage.srCore.srConfig.WEB_ROOT, StaticImageHandler,
             {"path": os.path.join(sickrage.srCore.srConfig.GUI_DIR, 'images')}),

            # css
            (r'%s/css/(.*)' % sickrage.srCore.srConfig.WEB_ROOT, StaticFileHandler,
             {"path": os.path.join(sickrage.srCore.srConfig.GUI_DIR, 'css')}),

            # scss
            (r'%s/scss/(.*)' % sickrage.srCore.srConfig.WEB_ROOT, StaticFileHandler,
             {"path": os.path.join(sickrage.srCore.srConfig.GUI_DIR, 'scss')}),

            # fonts
            (r'%s/fonts/(.*)' % sickrage.srCore.srConfig.WEB_ROOT, StaticFileHandler,
             {"path": os.path.join(sickrage.srCore.srConfig.GUI_DIR, 'fonts')}),

            # javascript
            (r'%s/js/(.*)' % sickrage.srCore.srConfig.WEB_ROOT, StaticFileHandler,
             {"path": os.path.join(sickrage.srCore.srConfig.GUI_DIR, 'js')}),

            # videos
        ] + [(r'%s/videos/(.*)' % sickrage.srCore.srConfig.WEB_ROOT, StaticFileHandler,
              {"path": self.video_root})])

        self.server = HTTPServer(self.app, no_keep_alive=True)

        if sickrage.srCore.srConfig.ENABLE_HTTPS: self.server.ssl_options = {
            "certfile": sickrage.srCore.srConfig.HTTPS_CERT,
            "keyfile": sickrage.srCore.srConfig.HTTPS_KEY
        }

        try:
            self.server.listen(sickrage.srCore.srConfig.WEB_PORT, None)
        except socket.error as e:
            print(e.message)
            raise

        # launch browser window
        if all([not sickrage.NOLAUNCH, sickrage.srCore.srConfig.LAUNCH_BROWSER]):
            threading.Thread(None,
                             lambda: launch_browser(
                                 ('http', 'https')[sickrage.srCore.srConfig.ENABLE_HTTPS],
                                 get_lan_ip(),
                                 sickrage.srCore.srConfig.WEB_PORT
                             )).start()

        # clear mako cache folder
        makocache = os.path.join(sickrage.srCore.srConfig.CACHE_DIR, 'mako')
        if os.path.isdir(makocache):
            shutil.rmtree(makocache)

        sickrage.srCore.srLogger.info("SiCKRAGE :: STARTED")
        sickrage.srCore.srLogger.info("SiCKRAGE :: VERSION:[{}]".format(sickrage.srCore.VERSIONUPDATER.updater.version))
        sickrage.srCore.srLogger.info("SiCKRAGE :: CONFIG:[{}]".format(sickrage.CONFIG_FILE))
        sickrage.srCore.srLogger.info("SiCKRAGE :: URL:[{}://{}:{}/]".format(
            ('http', 'https')[sickrage.srCore.srConfig.ENABLE_HTTPS],
            get_lan_ip(), sickrage.srCore.srConfig.WEB_PORT))