comparison libervia/server/server.py @ 1242:8f39d98416c5

server: added a child for common cache
author Goffi <goffi@goffi.org>
date Sun, 19 Apr 2020 22:56:15 +0200
parents 14c0f666a93d
children 079e8eb6e327
comparison
equal deleted inserted replaced
1241:921e9f2a97af 1242:8f39d98416c5
21 import sys 21 import sys
22 import urllib.parse 22 import urllib.parse
23 import urllib.request, urllib.error 23 import urllib.request, urllib.error
24 import time 24 import time
25 import copy 25 import copy
26 from pathlib import Path
26 from twisted.application import service 27 from twisted.application import service
27 from twisted.internet import reactor, defer, inotify 28 from twisted.internet import reactor, defer, inotify
28 from twisted.web import server 29 from twisted.web import server
29 from twisted.web import static 30 from twisted.web import static
30 from twisted.web import resource as web_resource 31 from twisted.web import resource as web_resource
862 863
863 # media dirs 864 # media dirs
864 # FIXME: get rid of dirname and "/" in C.XXX_DIR 865 # FIXME: get rid of dirname and "/" in C.XXX_DIR
865 self.putChildAll(os.path.dirname(C.MEDIA_DIR).encode('utf-8'), 866 self.putChildAll(os.path.dirname(C.MEDIA_DIR).encode('utf-8'),
866 ProtectedFile(self.media_dir)) 867 ProtectedFile(self.media_dir))
868
867 self.cache_resource = web_resource.NoResource() 869 self.cache_resource = web_resource.NoResource()
868 self.putChildAll(C.CACHE_DIR.encode('utf-8'), self.cache_resource) 870 self.putChildAll(C.CACHE_DIR.encode('utf-8'), self.cache_resource)
871 self.cache_resource.putChild(
872 b"common", ProtectedFile(str(self.cache_root_dir / Path("common"))))
869 873
870 # redirections 874 # redirections
871 for root in self.roots: 875 for root in self.roots:
872 root._initRedirections(self.options) 876 root._initRedirections(self.options)
873 877