Skip to content

Configuration

Zachary Smith edited this page Apr 30, 2023 · 4 revisions

The appearance of generated pages are customisable via a config.toml file. Create a subdirectory /.pythonwebio relative to were the project will be called from, and create a config.toml file inside.

.
├── app.py
└── .pythonwebio/
    └── config.toml

Example config.toml

[script]
filepath = "tests/colors_example.py"
entrypoint = "main"

[page]
name = "Python web I/O App"
icon = "🎯"
css = [
    "https://unpkg.com/[email protected]/normalize.css",
    "https://unpkg.com/simpledotcss/simple.min.css",
]

[about]
author = "Zachary"
profile = "https://github.com/Cutwell"
description = "Generate a webpage as a GUI for a Python script, and serve from anywhere."

[project]
homepage = "https://github.com/Cutwell/python-web-io"
license = "https://github.com/Cutwell/python-web-io/blob/main/LICENSE"
issues = "https://github.com/Cutwell/python-web-io/issues/new"

[flask]
host = '127.0.0.1'
port = 5000
debug = false

Note: command line arguments such as --source and --debug override their config.toml equivalents script.filepath and flask.debug

[script]

filepath Rather than provide a script filepath via command line, an app filepath can also be defined here.
entrypoint Python scripts using the typical if __name__ == '__main__': main() will not run, as this check will fail. To resolve this, a function name can be supplied as an entrypoint for the script, and will be called to begin execution.

[page]

name Webapp name, used as the website / tab title.
icon Webapp icon, used in bookmarks and in the tab.
css Drop-in CSS styling is supported and encouraged to customise a web-app to user preference. A curated list of drop-in stylesheets can be found here. This option can be a list of stylesheets or a single item.

[about]

These options populate the About modal, accessible from the page footer.

author Author's name / online alias.
profile Author social link, e,g.: GitHub, Twitter, etc.
description A short description to summarise the webapp.

[project]

These options populate the Help modal, accessible from the page footer.

homepage A link to the project homepage, for instance on GitHub.
license A link to the license the project is distributed under.
issues A link to a forum / issue tracker for reporting bugs users may encounter.

[flask]

These options are for the underlying Flask server:

host IP address for the server to use.
port Port number the server will be hosted on.
debug Boolean to enable debug mode.
Clone this wiki locally