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.
Documentation
Check out the wiki.
Quickstart
Install python-web-io
locally using:
pip install python-web-io
Or via poetry
using:
poetry add python_web_io
If evaluating / testing python-web-io
, install dependencies for the example apps using:
poetry add python_web_io --with examples
After installing the project, some environment setup is required:
Required setup
Create an app.py
file containing your script, a config.toml
setting the script filepath and entrypoint, and an .envrc
file to store project secrets. (Note: remember to add .envrc
to your .gitignore
). Look for example apps in /examples
.
.
├── .envrc
├── config.toml
└── app.py
Create the following simple config.toml
:
[script]
filepath = "app.py"
entrypoint = "main" # if your app has no entrypoint, remove this parameter.
Add the following environment variables to your .envrc
. (Note: remember to activate the .envrc
in your terminal using direnv allow
)
# server env vars
export PYTHON_WEB_IO_SECRET=""
export PYTHON_WEB_IO_CONFIG=".pythonwebio/config.toml" # defaults to .pythonwebio/config.toml if not set
Generate a random key for PYTHON_WEB_IO_SECRET
using this python command line snippet:
python -c 'import secrets; print(secrets.token_hex())'
If testing wikipedia_assistant.py
, an OpenAI API key will also need to be set.
export OPENAI_API_KEY=""
Running the webapp
We recommend running python_web_io
using uvicorn
:
poetry run uvicorn python_web_io.main:app
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file python_web_io-0.2.2.tar.gz
.
File metadata
- Download URL: python_web_io-0.2.2.tar.gz
- Upload date:
- Size: 11.4 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68a9b5c61cfc14bbc18dceb8ee1a99a23d3e808bcc2aaa7f5ade2a497d633b41 |
|
MD5 | c051f67772a7c63f26c741441e678c53 |
|
BLAKE2b-256 | 7fc453fdf41e6ddb3e393b8dc6f13a80ce9614f228f5c2978fa9e8842a5c71c9 |
File details
Details for the file python_web_io-0.2.2-py3-none-any.whl
.
File metadata
- Download URL: python_web_io-0.2.2-py3-none-any.whl
- Upload date:
- Size: 12.1 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | c9a96a01f5db6d3eeab921be8a841203241cc25920c8b152bb93238b5dc733d4 |
|
MD5 | a7d8643f3c12c0c05f5b8e7faefc3f85 |
|
BLAKE2b-256 | 003b24710784aef03a0374fdf587feeafcb37d69edc870a358de878cb08feacc |