gws.base.web.site¶
Web site.
Source code: gws.base.web.site
Module Contents¶
- class gws.base.web.site.Config(*args, **kwargs)¶
Bases:
gws.ConfigWeb site the server responds to.
- assets: WebDirConfig | None¶
Directory for assets.
- contentSecurityPolicy: str = "default-src 'self'; img-src * data: blob:"¶
Content security policy for the site.
- cors: CorsConfig | None¶
CORS configuration.
- errorPage: gws.ext.config.template | None¶
Template for HTTP error pages. (deprecated in 8.4)
- permissionsPolicy: str = 'geolocation=(self), camera=(), microphone=()'¶
Permissions policy for the site.
- rewrite: list[RewriteRuleConfig] | None¶
Rewrite rules. (deprecated in 8.4)
- rewriteRules: list[RewriteRuleConfig] | None¶
Rules to rewrite incoming URLs and URLs generated by the server.
- root: WebDirConfig | None¶
Directory for static documents.
- class gws.base.web.site.CorsConfig(*args, **kwargs)¶
Bases:
gws.ConfigCORS headers added to responses, to allow cross-origin requests.
- gws.base.web.site.DEFAULT_ASSETS_DIR = '/data/assets'¶
- gws.base.web.site.DEFAULT_REWRITE_RULES¶
- gws.base.web.site.DEFAULT_WEB_DIR = '/data/web'¶
- class gws.base.web.site.Object¶
Bases:
gws.WebSiteWeb site.
- configure()¶
Configuration hook.
Called when the node is initialized. Raising an exception here aborts the creation of the node.
- url_for(req, path, mode, **params)¶
Create a URL for a request path, applying the reversed rewrite rules.
If the path, or the rewritten path, is an absolute URL, only the parameters are added. In the
absoluteandcanonicalmodes, the URL gets the scheme of the request. The host is the canonical host in thecanonicalmode, and the request host and port otherwise or if there is no canonical host.- Parameters:
req – Web requester.
path – Request path.
mode –
absolute,relativeorcanonical.**params – Extra GET parameters.
- Returns:
A URL.
- Raises:
gws.BadRequestError – If an absolute URL is requested and there is no host.
- class gws.base.web.site.RewriteRuleConfig(*args, **kwargs)¶
Bases:
gws.ConfigURL rewrite rule.
- options: dict | None¶
Additional options.
- class gws.base.web.site.SSLConfig(*args, **kwargs)¶
Bases:
gws.ConfigSSL certificate and HSTS settings.
- crt: gws.FilePath¶
Certificate bundle location.
- hsts: gws.Duration = '365d'¶
Max. age for the Strict-Transport-Security header.
- key: gws.FilePath¶
Private key file location.
- class gws.base.web.site.WebDirConfig(*args, **kwargs)¶
Bases:
gws.ConfigDirectory served over the web.
- dir: gws.DirPath¶
Directory path.