MCPcopy Index your code
hub / github.com/pywebio/PyWebIO / config

Function config

pywebio/platform/page.py:259–358  ·  view source on GitHub ↗

PyWebIO application configuration :param str title: Application title :param str description: Application description :param str theme: Application theme. Available themes are: ``dark``, ``sketchy``, ``minty``, ``yeti``. You can also use environment variable ``PYWEBIO_THEME`` to

(*, title=None, description=None, theme=None, js_code=None, js_file=[], css_style=None, css_file=[],
           manifest=True)

Source from the content-addressed store, hash-verified

257
258
259def config(*, title=None, description=None, theme=None, js_code=None, js_file=[], css_style=None, css_file=[],
260 manifest=True):
261 """PyWebIO application configuration
262
263 :param str title: Application title
264 :param str description: Application description
265 :param str theme: Application theme. Available themes are: ``dark``, ``sketchy``, ``minty``, ``yeti``.
266 You can also use environment variable ``PYWEBIO_THEME`` to specify the theme (with high priority).
267
268 :demo_host:`Theme preview demo </theme>`
269
270 .. collapse:: Open Source Credits
271
272 The dark theme is modified from ForEvolve&#x27;s `bootstrap-dark <https://github.com/ForEvolve/bootstrap-dark>`_.
273 The sketchy, minty and yeti theme are from `bootswatch <https://bootswatch.com/4/>`_.
274
275 :param str js_code: The javascript code that you want to inject to page.
276 :param str/list js_file: The javascript files that inject to page, can be a URL in str or a list of it.
277 :param str css_style: The CSS style that you want to inject to page.
278 :param str/list css_file: The CSS files that inject to page, can be a URL in str or a list of it.
279 :param bool/dict manifest: `Web application manifest <https://developer.mozilla.org/en-US/docs/Web/Manifest>`_ configuration.
280 This feature allows you to add a shortcut to the home screen of your mobile device, and launch the app like a native app.
281 If set to ``True``, the default manifest will be used. You can also specify the manifest content in dict.
282 If ``False``, the manifest will be disabled.
283
284 .. collapse:: Note for icon configuration
285
286 Currently, the `icons <https://developer.mozilla.org/en-US/docs/Web/Manifest/icons>`_ field of the manifest
287 is not supported. Instead, you can use the ``icon`` field to specify the icon url.
288
289 ``config()`` can be used in 2 ways: direct call and decorator.
290 If you call ``config()`` directly, the configuration will be global.
291 If you use ``config()`` as decorator, the configuration will only work on single PyWebIO application function.
292 ::
293
294 config(title="My application") # global configuration
295
296 @config(css_style="* { color:red }") # only works on this application
297 def app():
298 put_text("hello PyWebIO")
299
300 .. note:: The configuration will affect all sessions
301
302 ``title`` and ``description`` are used for SEO, which are provided when indexed by search engines.
303 If no ``title`` and ``description`` set for a PyWebIO application function,
304 the `docstring <https://www.python.org/dev/peps/pep-0257/>`_ of the function will be used as title and description by default::
305
306 def app():
307 \"""Application title
308
309 Application description...
310 (A empty line is used to separate the description and title)
311 \"""
312 pass
313
314 The above code is equal to::
315
316 @config(title="Application title", description="Application description...")

Callers 3

theme.pyFile · 0.90
get_appFunction · 0.90
seoFunction · 0.85

Calls 1

DecoratorClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…