/redis-clinterwebz

Primary LanguagePythonBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

redis-clinterwebz: a redis-cli in your browser

screenshot

This project is a browser-based redis-cli-like interface. It is mainly intended to serve as the interactive backbone for the https://redis.io website. The project boasts:

  • An arcane out-of-the-box TTY experience
  • Multiple named Redis databases (e.g. latest, unstable...)
  • Key namespacing per DB
  • Opt-in per page context (allowing it to be used in the same website across multiple pages)
  • Embeddable JavaScript code
  • ... and much more!

Getting started

You can use docker-compose:

  1. Clone this repository
  2. Change directory to the repository
  3. Do docker-compose up to spin up the app, a webserver and an unstable Redis

The app should be accessible in your browser at http://localhost

Running the application for development

  1. Clone this repository
  2. Change directory to the repository
  3. (Recommended) Use virtualenv: virtualenv -p 3.9 venv; source venv/bin/activate
  4. Install the app: pip install -e .
  5. Copy-paste this to your terminal:
    export FLASK_APP=interwebz
    export FLASK_ENV=development
    export INTERWEBZ_JSON_SETTINGS=`pwd`/sample_settings.json
  6. To run: flask run

The app should be accessible in your browser at http://localhost:5000

Redis Server

To function correctly, the application requires one or more Redis servers.

The minimal Redis version required is 7.0.0 (until it is released, please install directly from the source at the unstable branch of the Redis repository).

An example for a hardend ACL profile is included in the redis directory. To use it:

cd redis
redis-server redis.conf

Deploying on k8s

WIP

# kubectl port-forward --namespace=ingress-nginx service/ingress-nginx-controller 8080:80
# https://kubernetes.github.io/ingress-nginx/deploy/#quick-start
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.1.0/deploy/static/provider/cloud/deploy.yaml
make up

Configuration

To override the defaults (see default_settings.py), you can provide your own settings file via the INTERWEBZ_SETTINGS environment variable, like so:

EXPORT INTERWEBS_SETTINGS=/path/to/your/settings.py
flask run

Alternatively, you can also use a JSON file for the same purpose (see sample_settings.json) via the INTERWEBZ_JSON_SETTINGS environment variable.

HTML redis-cli element

To embed in an HTML page:

  1. Import the cli.js script.
  2. Add a form element(s) with the redis-cli class.

Attributes

The redis-cli element supports these attributes:

  • dbid: the database ID to use, defaults to the first defined database.
  • asciiart: controls ASCII art display

TODO

  • Embedded comments inline :)
  • Testing
  • Deployment
  • Request/IP throttling
  • ...