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)
else:
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
else:
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
2
Answers
If you need to generate HTML with
zulu_extracts
then change the linesto
But it would be much better to do this kind of styling in the place where the rest of your HTML is generated.