GGUF Model Catalog Editor (Frontend) - Mungert69/GGUFModelBuilder GitHub Wiki
This file defines the main Flask web application for a Redis-backed model catalog editor. It provides a user-friendly web interface for managing model entries stored in a Redis database.
- Redis connection configuration
- Model browsing with pagination
- Advanced search capabilities
- CRUD operations (Create, Read, Update, Delete)
- Import/export functionality
- Backup and restore operations
- Secure configuration storage
app = Flask(__name__)
app.secret_key = 'your_secret_key_here'
app.jinja_env.filters['get_field_type'] = get_field_type
- Creates Flask application instance
- Sets up secret key for session security
- Registers custom Jinja filter for field type detection
- Ensures secure directory exists for configuration files
Functions:
-
get_config()
: Loads Redis connection settings from secure JSON file -
save_config()
: Saves updated configuration to secure storage
Route:
-
/settings
: Web form for updating Redis connection parameters
def get_catalog():
config = get_config()
return init_redis_catalog(
host=config['host'],
port=config['port'],
ssl=config['ssl'],
...
)
- Initializes connection using saved configuration
- Leverages
init_redis_catalog
utility
Route | Method | Description |
---|---|---|
/ |
GET | Lists models with pagination |
/search |
GET/POST | Search models by ID/all fields/specific field |
/edit/<model_id> |
GET/POST | Edit existing model |
/add |
GET/POST | Add new model |
/import |
GET/POST | Import models from JSON |
/export |
GET | Export catalog to JSON |
/backup |
GET/POST | Create/restore backups |
/delete/<model_id> |
POST | Delete model |
Field Handling:
def get_field_type(value):
"""Determine field type for display"""
if isinstance(value, bool):
return "boolean"
elif isinstance(value, int):
return "number"
...
Search Utilities:
def _value_matches_search(value, search_term):
"""Flexible matching for search"""
...
def _convert_to_search_string(value):
"""Convert value to searchable string"""
...
Uses Jinja2 templates for all user interfaces:
-
index.html
: Main catalog view -
edit_model.html
: Model editing form -
add_model.html
: New model form -
search.html
: Search interface -
settings.html
: Configuration form
- 🔒 Encrypted storage of Redis credentials
- 💬 Flash messages for user feedback
- ✅ Comprehensive input validation
- 🛡️ Error handling for all major operations
- 🔄 Session management for secure interactions
if __name__ == '__main__':
app.run(debug=True)
- Runs in debug mode when executed directly
- Auto-reloads on code changes
- Detailed error pages during development
- Set proper secret key in production
- Configure WSGI server for production use
- Set up proper SSL/TLS encryption
- Restrict access to configuration endpoints