lbry-sdk/lbrynet/lbrynet_daemon/DaemonServer.py

29 lines
882 B
Python
Raw Normal View History

import logging
import os
from twisted.internet import defer
2016-10-23 07:17:24 +02:00
from lbrynet.conf import settings
from lbrynet.lbrynet_daemon.Daemon import Daemon
from lbrynet.lbrynet_daemon.Resources import LBRYindex, HostedEncryptedFile, EncryptedFileUpload
2016-10-27 21:18:25 +02:00
from lbrynet.conf import settings
log = logging.getLogger(__name__)
class DaemonServer(object):
def _setup_server(self):
ui_path = os.path.join(settings.ensure_data_dir(), "lbry-ui", "active")
2016-10-23 07:17:24 +02:00
self.root = LBRYindex(ui_path)
self._api = Daemon(self.root)
2016-09-27 20:18:16 +02:00
self.root.putChild("view", HostedEncryptedFile(self._api))
self.root.putChild("upload", EncryptedFileUpload(self._api))
self.root.putChild(settings.API_ADDRESS, self._api)
return defer.succeed(True)
def start(self):
d = self._setup_server()
d.addCallback(lambda _: self._api.setup())
return d