Files
ComfyUI-Lora-Manager/py/routes/checkpoints_routes.py
Will Miao c987338c84 Add Checkpoints feature with routes, template, and JavaScript integration
- Introduced CheckpointsRoutes for managing checkpoints-related endpoints and handling the checkpoints page.
- Added checkpoints.html template for rendering the checkpoints interface with a work-in-progress message.
- Implemented checkpoints.js to manage the initialization of the Checkpoints page and its components.
- Updated LoraManager to include checkpoints routes in the application setup, enhancing overall functionality.
2025-03-20 10:50:46 +08:00

45 lines
1.4 KiB
Python

import os
from aiohttp import web
import jinja2
import logging
from ..config import config
from ..services.settings_manager import settings
logger = logging.getLogger(__name__)
logging.getLogger('asyncio').setLevel(logging.CRITICAL)
class CheckpointsRoutes:
"""Route handlers for Checkpoints management endpoints"""
def __init__(self):
self.template_env = jinja2.Environment(
loader=jinja2.FileSystemLoader(config.templates_path),
autoescape=True
)
async def handle_checkpoints_page(self, request: web.Request) -> web.Response:
"""Handle GET /checkpoints request"""
try:
template = self.template_env.get_template('checkpoints.html')
rendered = template.render(
is_initializing=False,
settings=settings,
request=request
)
return web.Response(
text=rendered,
content_type='text/html'
)
except Exception as e:
logger.error(f"Error handling checkpoints request: {e}", exc_info=True)
return web.Response(
text="Error loading checkpoints page",
status=500
)
def setup_routes(self, app: web.Application):
"""Register routes with the application"""
app.router.add_get('/checkpoints', self.handle_checkpoints_page)