CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-flask-admin

Simple and extensible admin interface framework for Flask

86

1.30x

Quality

Pending

Does it follow best practices?

Impact

86%

1.30x

Average score across 10 eval scenarios

Overview
Eval results
Files

redis-integration.mddocs/

Redis CLI Integration

Redis command-line interface integration providing an interactive Redis console within Flask-Admin. This allows administrators to execute Redis commands directly through the web interface.

Capabilities

Redis CLI View

Interactive Redis console that provides a web-based interface for executing Redis commands with safety checks and formatted output.

from flask_admin.contrib.rediscli import RedisCli

class RedisCli(BaseView):
    def __init__(
        self,
        redis,
        name=None,
        category=None,
        endpoint=None,
        url=None
    ):
        """
        Redis CLI view for web-based Redis command execution.
        
        Parameters:
        - redis: Redis connection object
        - name: View name (optional)
        - category: View category for menu organization
        - endpoint: Base endpoint name
        - url: Base URL path
        """

Redis Command Execution

Built-in command parsing, validation, and execution system with error handling and result formatting.

def _execute_command(self, name, args):
    """
    Execute Redis command with validation and error handling.
    
    Parameters:
    - name: str, Redis command name
    - args: tuple, Command arguments
    
    Returns:
    Formatted HTML response with command results
    """

def _parse_cmd(self, cmd):
    """
    Parse command string using shell-like syntax.
    
    Parameters:
    - cmd: str, Raw command string to parse
    
    Returns:
    tuple: Parsed command parts
    """

Command Safety and Remapping

Command filtering and remapping system to prevent dangerous operations and provide user-friendly aliases.

# Command configuration attributes
remapped_commands = {
    'del': 'delete'
}

excluded_commands = set(('pubsub', 'set_response_callback', 'from_url'))

Built-in Help System

Interactive help system providing command documentation and usage information.

def _cmd_help(self, *args):
    """
    Built-in help command implementation.
    
    Parameters:
    - args: Optional command name for specific help
    
    Returns:
    Help text for specified command or general help
    """

Error Handling

Comprehensive error handling with user-friendly error messages and exception management.

class CommandError(Exception):
    """Redis CLI command error exception."""

def _error(self, msg):
    """
    Format error message as HTML response.
    
    Parameters:
    - msg: str, Error message to format
    
    Returns:
    HTML formatted error response
    """

Usage Examples

Basic Redis CLI Setup

from flask import Flask
from flask_admin import Admin
from flask_admin.contrib.rediscli import RedisCli
import redis

app = Flask(__name__)
admin = Admin(app)

# Create Redis connection
redis_client = redis.Redis(host='localhost', port=6379, db=0)

# Add Redis CLI to admin interface
admin.add_view(RedisCli(
    redis_client,
    name='Redis Console',
    category='Tools'
))

Custom Redis CLI with Authentication

import redis
from flask_admin.contrib.rediscli import RedisCli

# Redis with authentication
redis_client = redis.Redis(
    host='localhost',
    port=6379,
    password='your-password',
    decode_responses=True
)

class SecureRedisCli(RedisCli):
    def is_accessible(self):
        # Add your security checks here
        return current_user.is_admin()

admin.add_view(SecureRedisCli(
    redis_client,
    name='Redis Admin',
    category='Database Tools'
))

Install with Tessl CLI

npx tessl i tessl/pypi-flask-admin

docs

appengine-integration.md

core-admin.md

file-admin.md

forms.md

geoalchemy-integration.md

helpers-utilities.md

index.md

model-views.md

mongoengine-integration.md

redis-integration.md

sqlalchemy-integration.md

tile.json