use UI downloaded to temp folder at startup
This commit is contained in:
parent
2486ae6d3f
commit
a55e3d8578
2 changed files with 26 additions and 7 deletions
|
@ -1120,6 +1120,10 @@ class LBRYDaemonCommandHandler(object):
|
|||
|
||||
|
||||
class LBRYindex(resource.Resource):
|
||||
def __init__(self, ui_dir):
|
||||
resource.Resource.__init__(self)
|
||||
self.ui_dir = ui_dir
|
||||
|
||||
isLeaf = False
|
||||
|
||||
def _delayed_render(self, request, results):
|
||||
|
@ -1136,7 +1140,7 @@ class LBRYindex(resource.Resource):
|
|||
log.info(r)
|
||||
return "<html><table style='width:100%'>" + ''.join(r) + "</html>"
|
||||
|
||||
return static.File("./dist/index.html").render_GET(request)
|
||||
return static.File(os.path.join(self.ui_dir, "index.html")).render_GET(request)
|
||||
|
||||
|
||||
class LBRYFileRender(resource.Resource):
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
import argparse
|
||||
import logging
|
||||
import tempfile
|
||||
import os
|
||||
import shutil
|
||||
|
||||
from StringIO import StringIO
|
||||
from zipfile import ZipFile
|
||||
from urllib import urlopen
|
||||
|
||||
from twisted.web import server, static
|
||||
from twisted.internet import reactor, defer
|
||||
|
@ -38,18 +45,26 @@ def start():
|
|||
|
||||
log.info("Starting lbrynet-daemon from command line")
|
||||
|
||||
tmpdir = tempfile.mkdtemp()
|
||||
url = urlopen("https://rawgit.com/lbryio/lbry-web-ui/master/dist.zip")
|
||||
z = ZipFile(StringIO(url.read()))
|
||||
z.extractall(tmpdir)
|
||||
|
||||
|
||||
args = parser.parse_args()
|
||||
daemon = LBRYDaemon()
|
||||
daemon.setup(args.wallet, args.update)
|
||||
|
||||
root = LBRYindex()
|
||||
root.putChild("css", static.File("./css"))
|
||||
root.putChild("font", static.File("./font"))
|
||||
root.putChild("img", static.File("./img"))
|
||||
root.putChild("js", static.File("./js"))
|
||||
root = LBRYindex(tmpdir)
|
||||
root.putChild("css", static.File(os.path.join(tmpdir, "css")))
|
||||
root.putChild("font", static.File(os.path.join(tmpdir, "font")))
|
||||
root.putChild("img", static.File(os.path.join(tmpdir, "img")))
|
||||
root.putChild("js", static.File(os.path.join(tmpdir, "js")))
|
||||
root.putChild(API_ADDRESS, daemon)
|
||||
root.putChild("webapi", LBRYDaemonWeb())
|
||||
root.putChild("view", LBRYFileRender())
|
||||
reactor.listenTCP(API_PORT, server.Site(root), interface=API_INTERFACE)
|
||||
|
||||
reactor.run()
|
||||
|
||||
shutil.rmtree(tmpdir)
|
Loading…
Reference in a new issue