Help Topics for web

Sample CLI

gway vbox render-error

References

Signature

(title: str, message: str, *, back_link: bool = True, target: str = 'uploads') -> str

Docstring

Helper for error display with optional link back to upload main page.



Sample CLI

gway web.app build-url

Signature

(*args, **kwargs)

Sample CLI

gway web.app current-endpoint

References

Signature

()

Docstring

Return the canonical endpoint path for the current request (the project route prefix). Falls back to gw.context['current_endpoint'], or None.



Sample CLI

gway web.app enabled-projects

Signature

()

Docstring

Return a set of all enabled web projects (for static.collect, etc).



Sample CLI

gway web.app setup

References

Signature

(*, app=None, project='web.site', path=None, home: str = None, views: str = 'view', apis: str =
'api', static='static', shared='shared', css='global', js='global', auth_required=False,
engine='bottle')

Docstring

Setup Bottle web application with symmetrical static/shared public folders. Only one project per app. CSS/JS params are used as the only static includes.

Sample CLI

gway web.app static-file

Signature

(filename, root, mimetype=True, download=False, charset='UTF-8', etag=None, headers=None)

Docstring

Open a file in a safe way and return an instance of :exc:`HTTPResponse` that can be sent back to the client. :param filename: Name or path of the file to send, relative to ``root``. :param root: Root path for file lookups. Should be an absolute directory path. :param mimetype: Provide the content-type header (default: guess from file extension) :param download: If True, ask the browser to open a `Save as...` dialog instead of opening the file with the associated program. You can specify a custom filename as a string. If not specified, the original filename is used (default: False). :param charset: The charset for files with a ``text/*`` mime-type. (default: UTF-8) :param etag: Provide a pre-computed ETag header. If set to ``False``, ETag handling is disabled. (default: auto-generate ETag header) :param headers: Additional headers dict to add to the response. While checking user input is always a good idea, this function provides additional protection against malicious ``filename`` parameters from breaking out of the ``root`` directory and leaking sensitive information to an attacker. Read-protected files or files outside of the ``root`` directory are answered with ``403 Access Denied``. Missing files result in a ``404 Not Found`` response. Conditional requests (``If-Modified-Since``, ``If-None-Match``) are answered with ``304 Not Modified`` whenever possible. ``HEAD`` and ``Range`` requests (used by download managers to check or continue partial downloads) are also handled automatically.

Sample CLI

gway web.app template

Signature

(*args, **kwargs)

Docstring

Get a rendered template as a string iterator. You can use a name, a filename or a template string as first parameter. Template rendering arguments can be passed as dictionaries or directly (as keyword arguments).

Sample CLI

gway web.app urlencode

Signature

(query, doseq=False, safe='', encoding=None, errors=None, quote_via=<function quote_plus at
0x00000256EF81D940>)

Docstring

Encode a dict or sequence of two-element tuples into a URL query string. If any values in the query arg are sequences and doseq is true, each sequence element is converted to a separate parameter. If the query arg is a sequence of two-element tuples, the order of the parameters in the output will match the order of parameters in the input. The components of a query arg may each be either a string or a bytes type. The safe, encoding, and errors parameters are passed down to the function specified by quote_via (encoding and errors only if a component is a str).

Sample CLI

gway web.auth clear

Signature

()

Docstring

Clear all registered auth challenges (for testing or reset).

Sample CLI

gway web.auth config-basic

References

Signature

(*, allow='work/basic_auth.cdv', engine='auto', optional=False)

Docstring

Register a basic authentication challenge using username/password pairs from a CDV. Username is the key, password is the value under 'b64' (base64-encoded). - If optional=True, failure does not block unless strict=True.

Sample CLI

gway web.auth create-user

References

Signature

(username, password, *, allow='work/basic_auth.cdv', overwrite=False, **fields)

Docstring

Create (or update if overwrite=True) a user in the CDV file for basic auth. Stores password as b64 field (base64 encoded). You can pass extra fields as kwargs.

Sample CLI

gway web.auth is-authorized

Signature

(*, strict=False)

Docstring

Runs all configured auth challenges in order. Returns True only if all required (or all, if strict=True) challenges succeed. - If strict=True: ALL challenges (required/optional) must succeed. - If strict=False: only required challenges must succeed; optional failures logged.

Sample CLI

gway web.auth is-enabled

Signature

()

Docstring

Returns True if any auth challenge is registered.

Sample CLI

gway web.cookies append

Signature

(name: str, label: str, value: str, sep: str = '|') -> list

Docstring

Append a (label=value) entry to the specified cookie, ensuring no duplicates (label-based). Useful for visited history, shopping cart items, etc.

Sample CLI

gway web.cookies check-consent

Signature

() -> bool

Docstring

Returns True if the user has accepted cookies (not blank, not None).

Sample CLI

gway web.cookies clear-all

Signature

(path='/')

Docstring

Remove all cookies in the request, blanking and expiring each.

Sample CLI

gway web.cookies get

Signature

(name: str, default=None)

Docstring

Get a cookie value from the request. Returns None if blank or unset.

Sample CLI

gway web.cookies list-all

Signature

() -> dict

Docstring

Returns a dict of all cookies from the request, omitting blanked cookies.

Sample CLI

gway web.cookies remove

Signature

(name, *args, **kwargs)

Sample CLI

gway web.cookies set

Signature

(name, value, *args, **kwargs)

Sample CLI

gway web.cookies update-mask-on-cookie-change

Signature

()

Docstring

Called when any cookie is set or removed, to update the mask record (if any) in masks.cdv.



Sample CLI

gway web.cookies view-my-mask

Signature

(*, claim=None, set_mask=None)

Docstring

View and manage mask linking for cookies. - GET: Shows current mask and allows claim or update. - POST (claim/set_mask): Claim a mask and save/load cookies to/from masks.cdv. If user claims an existing mask AND already has a mask cookie, ALL existing cookies (except cookies_accepted) are wiped before restoring the claimed mask. No wipe is performed when creating a new mask.

Sample CLI

gway web.cookies view-remove

Signature

(*, next='/cookies/cookie-jar', confirm=False)


Sample CLI

gway web.error unauthorized

Signature

(message='Unauthorized: You do not have access to this resource.', *, err=None, default=None)

Docstring

If in debug mode: show detailed error. If not in debug: return a 401 Unauthorized and a WWW-Authenticate header to trigger the browser auth dialog.

Sample CLI

gway web.error view-debug-error

References

Signature

(*, title='GWAY Debug Error', message='An error occurred.', err=None, status=500, default=None)

Docstring

Render a debug error view with detailed traceback and request info.

Sample CLI

gway web.nav get-current-url

Signature

()

Docstring

Returns the current full URL path (with querystring).

Sample CLI

gway web.nav get-selected-style

Signature

()

Docstring

(Deprecated for site-wide theme—use get_style instead.) Returns the CSS <link> href for the selected style for this user/session.

Sample CLI

gway web.nav get-style

References

Signature

()

Docstring

Returns the current user's preferred style path (to .css file), checking: - URL ?css= param (for preview/testing) - 'css' cookie - First available style, or '/static/styles/base.css' if none found This should be called by render_template for every page load.




Sample CLI

gway web.nav style-selector-form

Signature

(all_styles, selected_style, cookies_enabled, cookies_accepted, project)


Sample CLI

gway web.proxy setup-fallback-app

References

Signature

(*, endpoint: str, app=None, websockets: bool = False, path: str = '/', mode: str = 'extend',
callback=None)

Docstring

Create an HTTP (and optional WebSocket) fallback to the given endpoint. This asumes the given endpoint will replicate or provide missing functionality or the entire service if it can't be provided locally.

TODOs

# TODO: Implement a mode kwarg that defaults to "extend" and functions like this: # replace: Replace all paths in the received apps with the proxied endpoint. # extend: Redirect all paths not already configured to the proxy. # errors: Catch errors thrown by the app and redirect the failed calls to the proxy. # trigger: Use a callback function to check. Redirects when result is True. # Move this explanation to the docstring. # TODO: We need to use gw.unwrap_all instead and apply the proxy mode to each of the # apps found there, then we need to return all those apps in a collection. # collect apps by type # TODO: Test that this return is properly compatible with web.server.start_app after the fixes

Sample CLI

gway web.server is-local

References

Signature

(request=None, host=None)

Docstring

Returns True if the active HTTP request originates from the same machine that the server is running on (i.e., local request). Supports both Bottle and FastAPI (ASGI/WSGI). Args: request: Optionally, the request object (Bottle, Starlette, or FastAPI Request). host: Optionally, the bound host (for override or testing). Returns: bool: True if request is from localhost, else False.

Sample CLI

gway web.server iterable

Signature

(y)

Docstring

Check whether or not an object can be iterated over. Parameters ---------- y : object Input object. Returns ------- b : bool Return ``True`` if the object has an iterator method or is a sequence and ``False`` otherwise. Examples -------- >>> import numpy as np >>> np.iterable([1, 2, 3]) True >>> np.iterable(2) False Notes ----- In most cases, the results of ``np.iterable(obj)`` are consistent with ``isinstance(obj, collections.abc.Iterable)``. One notable exception is the treatment of 0-dimensional arrays:: >>> from collections.abc import Iterable >>> a = np.array(1.0) # 0-dimensional numpy array >>> isinstance(a, Iterable) True >>> np.iterable(a) False

Sample CLI

gway web.server start-app

References

Signature

(*, host='[WEBSITE_HOST|127.0.0.1]', port='[WEBSITE_PORT|8888]', ws_port='[WEBSOCKET_PORT|9000]',
debug=False, proxy=None, app=None, daemon=True, threaded=True, is_worker=False, workers=None)

Docstring

Start an HTTP (WSGI) or ASGI server to host the given application. - If `app` is a FastAPI instance, runs with Uvicorn (optionally on ws_port if set). - If `app` is a WSGI app, uses Paste+ws4py or Bottle. - If `app` is a zero-arg factory, it will be invoked (supporting sync or async factories). - If `app` is a list of apps, each will be run in its own thread (each on an incremented port; FastAPI uses ws_port if set).

Sample CLI

gway web.site publish-parts

Signature

(source, source_path=None, source_class=<class 'docutils.io.StringInput'>, destination_path=None,
reader=None, reader_name='standalone', parser=None, parser_name='restructuredtext', writer=None,
writer_name='pseudoxml', settings=None, settings_spec=None, settings_overrides=None,
config_section=None, enable_exit_status=False)

Docstring

Set up & run a `Publisher`, and return a dictionary of document parts. Dictionary keys are the names of parts. Dictionary values are `str` instances; encoding is up to the client, e.g.:: parts = publish_parts(...) body = parts['body'].encode(parts['encoding'], parts['errors']) See the `API documentation`__ for details on the provided parts. Parameters: see `publish_programmatically()`. __ https://docutils.sourceforge.io/docs/api/publisher.html#publish-parts

Sample CLI

gway web.site view-help

References

Signature

(topic='', *args, **kwargs)

Docstring

Render dynamic help based on GWAY introspection and search-style links. If there is an exact match in the search, show it at the top (highlighted).

TODOs

# TODO: Change the wat the help system works: Instead of just using the results of # gw.gelp at all times, compliment this result with other information.


Sample CLI

gway web.site view-readme

References

Signature

(*args, **kwargs)

Docstring

Render the README.rst file as HTML.