gws.base.web.site

Source code: gws.base.web.site

Module Contents

class gws.base.web.site.Config(*args, **kwargs)

Bases: gws.Config

Site (virtual host) configuration

assets: WebDocumentRootConfig | None

Root directory for assets.

canonicalHost: str = ''

Hostname for reversed URL rewriting.

contentSecurityPolicy: str = "default-src 'self'; img-src * data: blob:"

Content Security Policy for this site. (added in 8.1)

cors: CorsConfig | None

Cors configuration.

errorPage: gws.ext.config.template | None

Error page template.

host: str = '*'

Host name.

permissionsPolicy: str = 'geolocation=(self), camera=(), microphone=()'

Permissions Policy for this site. (added in 8.1)

rewrite: list[RewriteRuleConfig] | None

Rewrite rules.

root: WebDocumentRootConfig

Root directory for static documents.

class gws.base.web.site.CorsConfig(*args, **kwargs)

Bases: gws.Config

CORS configuration.

allowCredentials: bool = False

Access-Control-Allow-Credentials header.

allowHeaders: str = ''

Access-Control-Allow-Headers header.

allowMethods: str = ''

Access-Control-Allow-Methods header.

allowOrigin: str = ''

Access-Control-Allow-Origin header.

maxAge: int = 5

Access-Control-Max-Age header.

class gws.base.web.site.Object

Bases: gws.WebSite

Web site.

canonicalHost: str
contentSecurityPolicy: str
permissionsPolicy: str
ssl: bool
configure()

Configuration hook.

url_for(req, path, **params)

Rewrite a request path to an Url.

Parameters:
  • req – Web Requester.

  • path – Raw request path.

  • **kwargs – Extra GET params.

Returns:

A rewritten URL.

class gws.base.web.site.RewriteRuleConfig(*args, **kwargs)

Bases: gws.Config

Rewrite rule configuration.

options: dict | None

Additional options.

pattern: gws.Regex

Expression to match the url against.

reversed: bool = False

Reversed rewrite rule.

target: str

Target url with placeholders.

class gws.base.web.site.SSLConfig(*args, **kwargs)

Bases: gws.Config

SSL configuration.

crt: gws.FilePath

Crt bundle location.

hsts: gws.Duration = '365d'

HSTS max age. (added in 8.1)

key: gws.FilePath

Key file location.

class gws.base.web.site.WebDocumentRootConfig(*args, **kwargs)

Bases: gws.Config

Web-accessible directory.

allowMime: list[str] | None

Allowed mime types.

denyMime: list[str] | None

Disallowed mime types (from the standard list).

dir: gws.DirPath

Directory path.