http: Add HTTP_SERVER_{HOSTNAME,PORT} settings

This commit is contained in:
Stein Magnus Jodal 2012-11-08 23:07:42 +01:00
parent 93f6378cf5
commit e5053c929a
2 changed files with 29 additions and 3 deletions

View File

@ -4,7 +4,7 @@ import logging
import pykka
from mopidy import exceptions
from mopidy import exceptions, settings
try:
import cherrypy
@ -19,11 +19,14 @@ class HttpFrontend(pykka.ThreadingActor):
def __init__(self, core):
super(HttpFrontend, self).__init__()
self.core = core
cherrypy.config.update({
'server.socket_host': settings.HTTP_SERVER_HOSTNAME,
'server.socket_port': settings.HTTP_SERVER_PORT,
})
cherrypy.tree.mount(Root(self.core), '/')
def on_start(self):
logger.debug(u'Starting HTTP server')
cherrypy.tree.mount(Root(self.core), '/', {})
cherrypy.server.socket_port = 6680
cherrypy.server.start()
logger.info(u'HTTP server running at %s',
cherrypy.server.base())

View File

@ -78,6 +78,29 @@ FRONTENDS = (
u'mopidy.frontends.mpris.MprisFrontend',
)
#: Which address Mopidy's HTTP server should bind to.
#:
#: Used by :mod:`mopidy.frontends.http`.
#:
#: Examples:
#:
#: ``127.0.0.1``
#: Listens only on the IPv4 loopback interface. Default.
#: ``::1``
#: Listens only on the IPv6 loopback interface.
#: ``0.0.0.0``
#: Listens on all IPv4 interfaces.
#: ``::``
#: Listens on all interfaces, both IPv4 and IPv6.
HTTP_SERVER_HOSTNAME = u'127.0.0.1'
#: Which TCP port Mopidy's HTTP server should listen to.
#:
#: Used by :mod:`mopidy.frontends.http`.
#:
#: Default: 6680
HTTP_SERVER_PORT = 6680
#: Your `Last.fm <http://www.last.fm/>`_ username.
#:
#: Used by :mod:`mopidy.frontends.lastfm`.