Skip to content

Quickstart

Zachary Smith edited this page May 3, 2023 · 8 revisions

After installing the project, some environment setup is required:

Required setup

Create an app.py file containing your script, and an .envrc file to store project secrets. (Note: remember to add .envrc to your .gitignore) Look for example apps in ./python_web_io/tests.

.
├── .envrc
└── app.py

Add the following environment variables to your .envrc. (Note: remember to activate the .envrc in your terminal using direnv allow)

# flask server env vars
export FLASK_SECRET_KEY=""
export FLASK_SESSION_PERMANENT=false
export FLASK_SESSION_USE_SIGNER=true

# flask server-side sessions env var
export FLASK_SESSION_TYPE="filesystem"

Generate a random key for FLASK_SECRET_KEY using this python command line snippet:

python -c 'import secrets; print(secrets.token_hex())'

If testing linux_gpt.py, an OpenAI API key will also need to be set.

export OPENAI_API_KEY=""

Running the webapp

Installed using pip, you can call python-web-io as a CLI tool:

python_web_io

Using poetry, you can call it via:

poetry run python_web_io

Command line arguments

Whilst python-web-io is fully configurable via config.toml, some CLI arguments are made available for when using a non-default config.toml path, or testing an app.

Argument
--script="example.py" Optional Specify the file path for the app Python script.
--config="/.pythonwebio/config.toml" Optional Specify the file path for the app Python script.
--debug Optional Run the Flask server with debug output enabled.
Clone this wiki locally