Skip to main content

Generate a webpage as a GUI for a Python script, and serve from anywhere.

Project description

Python Web I/O

Generate a webpage as a GUI for a Python script, and serve from anywhere.

Usage

$ export SECRET_KEY="someSecureSecretKey"
$ python_web_io .\example.py
Argument
"example.py" Required Specify the file path for the app Python script / entrypoint.
--debug Optional Run the Flask server with debug output enabled.

Config

Magic

input() and print() both support the magic keyword argument. For input(), magic sets the type of the input html element. For print(), magic sets the element type.

Magic Default
input() button, checkbox, color, date, datetime-local, email, file, image, month, number, password, radio, range, search, tel, text, time, url, week text
print() style, img, address, footer, aside, header, h1..6, blockquote, p, b, abbr, code, em, i, mark, q, s, small, span, strong, p

Arguments

input() and print() both support the magic_args keyword argument. magic_args accepts a dictionary, which can be used to set attributes for the html element.

Cache

The user script is re-evaluated after each user interaction, to progress the script to the next input(), etc. This means expensive functions may be called more than once per session. To reduce latency, a cache decorator is made available through the python_web_io module. The @cache_to_file() decorator accepts a single argument: file_path, which indicates where the cache (a .pkl file) should be stored.

import python_web_io as io

@io.cache_to_file('cache.pickle')
def expensive_function(arg):
    # Calculate the result here
    return result

Cache is persistent across sessions, allowing multiple users to access it. Session specific data can be stored using session from flask.

from flask import session
session['some_var] = 'some_val'

Reserved keys for the session namespace are: io and counter.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_web_io-0.1.13.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

python_web_io-0.1.13-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file python_web_io-0.1.13.tar.gz.

File metadata

  • Download URL: python_web_io-0.1.13.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.9.2 Linux/5.15.90.1-microsoft-standard-WSL2

File hashes

Hashes for python_web_io-0.1.13.tar.gz
Algorithm Hash digest
SHA256 b07594454b3bcd0c8df815549f9258548c12921cbd9198288b4dc15936cbf14f
MD5 8f255a5caba8fc14de637c4bc1fedac0
BLAKE2b-256 60e77db9663852d0f48e8a6088dea89dea2a22b51fcb7c68a8b78af75b9ac95f

See more details on using hashes here.

File details

Details for the file python_web_io-0.1.13-py3-none-any.whl.

File metadata

  • Download URL: python_web_io-0.1.13-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.9.2 Linux/5.15.90.1-microsoft-standard-WSL2

File hashes

Hashes for python_web_io-0.1.13-py3-none-any.whl
Algorithm Hash digest
SHA256 7032c6f43c7b5fa2e19cbdce103e19f2fd9115fa99f2290484bf565118601674
MD5 410638212bf523d05a5b8f5bd073aefa
BLAKE2b-256 96fc1272547cf71cd44bc36f39e808acaac03a6b2e99d6fe11cbc15debd823d7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page