StaticFiles¶
-
class
plinth.web_server.
StaticFiles
(component_id, directory_map=None)[source]¶ Component to serve static files shipped with an app.
Any files in <app>/static directory will be automatically served on /static/<app>/ directory by FreedomBox. This allows each app to ship custom static files that are served by the web server.
However, in some rare circumstances, a system folder will need to be served on a path for the app to work. This component allows declaring such directories and the web paths they should be served on.
-
__init__
(component_id, directory_map=None)[source]¶ Initialize the component.
component_id should be a unique ID across all components of an app and across all components.
directory_map should be a dictionary with keys to be web paths and values to be absolute path of the directory on disk to serve. The static files from the directory are served over the given web path. The web path will be prepended with the FreedomBox’s configured base web path. For example, {‘/foo’: ‘/usr/share/foo’} means that ‘/usr/share/foo/bar.png’ will be served over ‘/plinth/foo/bar.png’ if FreedomBox is configured to be served on ‘/plinth’.
-