Merge branch 'ZenithDK/fix/check_static_dir' into develop
This commit is contained in:
commit
b3bd10017a
@ -2,6 +2,7 @@ from __future__ import unicode_literals
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
import pykka
|
import pykka
|
||||||
@ -62,13 +63,20 @@ class HttpFrontend(pykka.ThreadingActor, CoreListener):
|
|||||||
handlers.WebSocketHandler.broadcast(message)
|
handlers.WebSocketHandler.broadcast(message)
|
||||||
|
|
||||||
def _get_request_handlers(self):
|
def _get_request_handlers(self):
|
||||||
|
static_dir = self.config['http']['static_dir']
|
||||||
request_handlers = []
|
request_handlers = []
|
||||||
|
|
||||||
request_handlers.extend(self._get_app_request_handlers())
|
request_handlers.extend(self._get_app_request_handlers())
|
||||||
request_handlers.extend(self._get_static_request_handlers())
|
request_handlers.extend(self._get_static_request_handlers())
|
||||||
|
|
||||||
# Either default Mopidy or user defined path to files
|
# Either default Mopidy or user defined path to files
|
||||||
if self.config['http']['static_dir']:
|
if (static_dir and not os.path.exists(static_dir)):
|
||||||
|
logger.warning(
|
||||||
|
'Configured http/static_dir does not exist: %s\n'
|
||||||
|
' Falling back to default http handler', static_dir)
|
||||||
|
static_dir = None
|
||||||
|
|
||||||
|
if static_dir:
|
||||||
request_handlers.append((r'/(.*)', handlers.StaticFileHandler, {
|
request_handlers.append((r'/(.*)', handlers.StaticFileHandler, {
|
||||||
'path': self.config['http']['static_dir'],
|
'path': self.config['http']['static_dir'],
|
||||||
'default_filename': 'index.html',
|
'default_filename': 'index.html',
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user