File size: 571 Bytes
40c29ba
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from flask import url_for
def df_to_table_html(df, additional_class=None):
    classes = 'table table-striped table-bordered'

    if additional_class is not None:
        classes += f" {additional_class}"

    full_table_html = df.to_html(classes=classes, escape=False, index=False)

    # Modify the table HTML to add links to model names
    for model in df['Model']:
        model_link = f'<a href="{url_for("model_detail", model_name=model)}">{model}</a>'
        full_table_html = full_table_html.replace(f'>{model}<', f'>{model_link}<')
    return full_table_html