def index(self):
        """Render the app stats index page."""
        # Transform the raw data into pretty output for HTML
        yield """
<html>
<head>
    <title>Statistics</title>
<style>

th, td {
    padding: 0.25em 0.5em;
    border: 1px solid #666699;
}

table {
    border-collapse: collapse;
}

table.stats1 {
    width: 100%;
}

table.stats1 th {
    font-weight: bold;
    text-align: right;
    background-color: #CCD5DD;
}

table.stats2, h2 {
    margin-left: 50px;
}

table.stats2 th {
    font-weight: bold;
    text-align: center;
    background-color: #CCD5DD;
}

</style>
</head>
<body>
"""
        for title, scalars, collections in self.get_namespaces():
            yield (
                """
<h1>%s</h1>

<table class='stats1'>
    <tbody>
"""
                % title
            )
            for i, (key, value) in enumerate(scalars):
                colnum = i % 3
                if colnum == 0:
                    yield """
        <tr>"""
                yield (
                    """
            <th>%(key)s</th><td id='%(title)s-%(key)s'>%(value)s</td>"""
                    % vars()
                )
                if colnum == 2:
                    yield """
        </tr>"""

            if colnum == 0:
                yield """
            <th></th><td></td>
            <th></th><td></td>
        </tr>"""
            elif colnum == 1:
                yield """
            <th></th><td></td>
        </tr>"""
            yield """
    </tbody>
</table>"""

            for subtitle, headers, subrows in collections:
                yield (
                    """
<h2>%s</h2>
<table class='stats2'>
    <thead>
        <tr>"""
                    % subtitle
                )
                for key in headers:
                    yield (
                        """
            <th>%s</th>"""
                        % key
                    )
                yield """
        </tr>
    </thead>
    <tbody>"""
                for subrow in subrows:
                    yield """
        <tr>"""
                    for value in subrow:
                        yield (
                            """
            <td>%s</td>"""
                            % value
                        )
                    yield """
        </tr>"""
                yield """
    </tbody>
</table>"""
        yield """
</body>
</html>
"""
Render the app stats index page.
cherrypy/lib/cpstats.py