使用 Python Flask 在检测到 scam、pending 和 verified 等词时更改图标的颜色
Using Python Flask to change the colour of an icon when it detects a words like scam, pending and verified
我正在尝试更改 scam、pending 和 verified 等词旁边的圆圈图标的颜色。哪个已经显示在页面上以便在页面加载时显示图标的相应颜色。我附上了我的代码
import os
from app import app,db
from datetime import timedelta
from flask import render_template, request, flash,url_for,redirect,session,make_response,send_from_directory, send_file
from app.models import User,Watch,Group,Contact,Advert,Report,Tv
from app.stock_function import is_valid_email, check_login
import hashlib
import smtplib
from werkzeug.utils import secure_filename
from config import Config
from flask_mail import Mail, Message
mail = Mail(app)
@app.route('/whatsapptv')
def whatsapptv():
tv= Tv.query.all()
return render_template('tvlist.html',tvs=tv)
<div class="container">
<div class="center-div" style="width: auto">
</div>
{%if tvs %}
<table class="table table-hover table-responsive">
<div class="row">
<thead>
<th scope="col">S/N</th>
<th scope="col">Name</th>
<th scope="col">Phone Number</th>
<th scope="col"> Verified Business</th>
<th scope="col"> Remark</th>
</thead>
{%for tv in tvs%}
<tr>
<td> <h5>{{loop.index}}</h5></td>
<td> <h5>{{tv.name}}</h5></td>
<td><h4 >{{tv.group}}</h4> </td>
<td><h4>{{tv.description}} </h4> <i class="bx bxs-circle"></i> </td>
<td><h4 >{{tv.remark}}</h4> </td>
</td>
</tr>
{%endfor%}
</table>
</div>
{%else%}
<p>No Business available</p>
{%endif%}
</div>
<div>
通过您在模型中使用的参数更改“参数”来定义颜色。
<tr>
<td> <h5>{{loop.index}}</h5></td>
<td> <h5>{{tv.name}}</h5></td>
<td><h4 >{{tv.group}}</h4></td>
<td><h4>{{tv.description}} </h4>
{% if tv.parameter == 'verified' %}<i class="bx" style="color:green;" bxs-circle"></i>
{% elif tv.parameter == 'pending' %}<i class="bx" style="color:yellow;" bxs-circle"></i>
{% else %}<i class="bx" style="color:red;" bxs-circle"></i>{% endif %}</td>
<td><h4 >{{tv.remark}}</h4></td>
</td>
</tr>
我正在尝试更改 scam、pending 和 verified 等词旁边的圆圈图标的颜色。哪个已经显示在页面上以便在页面加载时显示图标的相应颜色。我附上了我的代码
import os
from app import app,db
from datetime import timedelta
from flask import render_template, request, flash,url_for,redirect,session,make_response,send_from_directory, send_file
from app.models import User,Watch,Group,Contact,Advert,Report,Tv
from app.stock_function import is_valid_email, check_login
import hashlib
import smtplib
from werkzeug.utils import secure_filename
from config import Config
from flask_mail import Mail, Message
mail = Mail(app)
@app.route('/whatsapptv')
def whatsapptv():
tv= Tv.query.all()
return render_template('tvlist.html',tvs=tv)
<div class="container">
<div class="center-div" style="width: auto">
</div>
{%if tvs %}
<table class="table table-hover table-responsive">
<div class="row">
<thead>
<th scope="col">S/N</th>
<th scope="col">Name</th>
<th scope="col">Phone Number</th>
<th scope="col"> Verified Business</th>
<th scope="col"> Remark</th>
</thead>
{%for tv in tvs%}
<tr>
<td> <h5>{{loop.index}}</h5></td>
<td> <h5>{{tv.name}}</h5></td>
<td><h4 >{{tv.group}}</h4> </td>
<td><h4>{{tv.description}} </h4> <i class="bx bxs-circle"></i> </td>
<td><h4 >{{tv.remark}}</h4> </td>
</td>
</tr>
{%endfor%}
</table>
</div>
{%else%}
<p>No Business available</p>
{%endif%}
</div>
<div>
通过您在模型中使用的参数更改“参数”来定义颜色。
<tr>
<td> <h5>{{loop.index}}</h5></td>
<td> <h5>{{tv.name}}</h5></td>
<td><h4 >{{tv.group}}</h4></td>
<td><h4>{{tv.description}} </h4>
{% if tv.parameter == 'verified' %}<i class="bx" style="color:green;" bxs-circle"></i>
{% elif tv.parameter == 'pending' %}<i class="bx" style="color:yellow;" bxs-circle"></i>
{% else %}<i class="bx" style="color:red;" bxs-circle"></i>{% endif %}</td>
<td><h4 >{{tv.remark}}</h4></td>
</td>
</tr>