Source code for peek_plugin_base.client.PeekPlatformDesktopHttpHookABC

from abc import ABCMeta

from txhttputil.site.BasicResource import BasicResource
from txhttputil.site.FileUnderlayResource import FileUnderlayResource


[docs]class PeekPlatformDesktopHttpHookABC(metaclass=ABCMeta): """ Peek Platform Site HTTP Hook The methods provided by this class apply to the HTTP sites served by the Client service for the mobile and desktop apps, and the Server service for the admin app. It is not the HTTP service that provides resources (vortex, etc) beween the server and the agent, worker and client. """ def __init__(self): self.__rootDesktopResource = FileUnderlayResource()
[docs] def addDesktopStaticResourceDir(self, dir: str) -> None: """ Add Site Static Resource Directory Calling this method sets up directory :code:`dir` to be served by the site. :param dir: The file system directory to be served. :return: None """ self.__rootDesktopResource.addFileSystemRoot(dir)
[docs] def addDesktopResource(self, pluginSubPath: bytes, resource: BasicResource) -> None: """ Add Site Resource Add a cusotom implementation of a served http resource. :param pluginSubPath: The resource path where you want to serve this resource. :param resource: The resource to serve. :return: None """ pluginSubPath = pluginSubPath.strip(b'/') self.__rootDesktopResource.putChild(pluginSubPath, resource)
@property def rootDesktopResource(self) -> BasicResource: """ Site Root Resource This returns the root site resource for this plugin. """ return self.__rootDesktopResource