How do I get return value on different color in front end

I have backend code written in python where it returns a number, I want to show the number in different color for certain threshold.

For example if the number is 15 and above it should show in red color

Here is the code:

def zulu_extracts(weather_input,datis=None):
    # This could be work intensive. Make your own conversion if you can avoid using datetime
    raw_utc = Root_class().date_time(raw_utc='HM')[-4:]
    raw_utc_dt = datetime.strptime(raw_utc,"%H%M")
    if datis:
        zulu_item_re = re.findall('[0-9]{4}Z', weather_input)
        zulu_item_re = re.findall('[0-9]{4}Z', weather_input)
    if zulu_item_re:
        zulu_weather = zulu_item_re[0][:-1]
        zulu_weather_dt = datetime.strptime(zulu_weather,"%H%M")
        diff = raw_utc_dt - zulu_weather_dt
        diff = int(diff.seconds/60)
        return diff
        zulu_weather = 'N/A'
        return zulu_weather

The front end is based on html,css and JS

I already searched on google and tried chat GPT but nothing seems to work

enter code here:
from colorama import Fore
numero = int(input("Tell me a number\n"))
if numero < 50:
print(Fore.RED + str(numero))
print(Fore.BLUE + str(numero))

If you need to generate HTML with zulu_extracts then change the lines

diff = int(diff.seconds/60)
return diff


diff = int(diff.seconds/60)
if diff >= 15:
    return '<span style="color: red">{}</span>'.format(diff)
return diff

But it would be much better to do this kind of styling in the place where the rest of your HTML is generated.

Back to Top