def UV(): currentStateAQI = IndexAirQuality() resultAQI = queryAQI() arrowAQI = arrowAQ() tempCurrentC = str(calcC()) tempCurrentC = tempCurrentC[:2] arrowHI = dirArrow() direction = dirHI() resultUVI = queryUV() colorHI = colorIndexHeat() colorAQI = colorIndexAir() colorUVI = colorUV() currentStateUVI = IndexUV() tipUVI = tipsUVI() noMedia = noMediaUV() indexHeatState = indexHeatStateColor() return render_template('UV.html', noMedia=noMedia, colorUVI=colorUVI, colorHI=colorHI, colorAQI=colorAQI, resultUVI=resultUVI, currentStateUVI=currentStateUVI, direction=direction, resultAQI=resultAQI, indexHeatState=indexHeatState, tempCurrentC=tempCurrentC, currentStateAQI=currentStateAQI, tipUVI=tipUVI, arrowHI=arrowHI, arrowAQI=arrowAQI)
def arrowAQ(): resultAQI = queryAQI() y.append(float(resultAQI)) if len(y) == 2: AQIndexDirection = y[1] - y.pop(0) if AQIndexDirection < 0: arrowAQI = Markup("<img src='../static/arrowDOWN.svg'>") return arrowAQI elif AQIndexDirection == 0: arrowAQI = Markup("<img src='../static/arrowDOWN.svg'>") return arrowAQI else: arrowAQI = Markup("<img src='../static/arrowUP.svg'>") return arrowAQI else: arrowAQI = '' return arrowAQI
def index(): currentStateAQI = IndexAirQuality() resultAQI = queryAQI() tipAQI = tipsAQI() tweetAQI(currentStateAQI, resultAQI, tipAQI) tipHI = tipsHI() tempCurrentC = calcC() direction = dirHI() indexHeatState = indexHeatStateColor() tweetHeat(tipHI) return render_template('index.html', resultAQI=resultAQI, indexHeatState=indexHeatState, tempCurrentC=tempCurrentC, currentStateAQI=currentStateAQI, tipAQI=tipAQI, tipHI=tipHI, direction=direction)
def IndexAirQuality(): resultAQI = queryAQI() if resultAQI < 50: currentStateAQI = 'Good' return currentStateAQI elif 51 > resultAQI and resultAQI <= 100: currentStateAQI = 'Moderate' return currentStateAQI elif 101 > resultAQI and resultAQI <= 150: currentStateAQI = 'Unhealthy-for-Sensitive-Groups' return currentStateAQI elif 151 > resultAQI and resultAQI <= 200: currentStateAQI = 'Unhealthy' return currentStateAQI elif 201 > resultAQI and resultAQI <= 300: currentStateAQI = 'Very-Unhealthy' return currentStateAQI else: currentStateAQI = 'Hazardous' return currentStateAQI
def noMediaAQI(): resultAQI = queryAQI() if resultAQI < 50: noMedia = 6 return noMedia elif 51 < resultAQI <= 100: noMedia = 7 return noMedia elif 101 < resultAQI <= 150: noMedia = 8 return noMedia elif 151 < resultAQI <= 200: noMedia = 9 return noMedia elif 201 < resultAQI <= 300: noMedia = 10 return noMedia else: noMedia = 11 return noMedia
def colorIndexAir(): resultAQI = queryAQI() if resultAQI < 50: colorAQI = 'Green' return colorAQI elif 51 < resultAQI <= 100: colorAQI = 'Yellow' return colorAQI elif 101 < resultAQI <= 150: colorAQI = 'Orange' return colorAQI elif 151 < resultAQI <= 200: colorAQI = 'Red' return colorAQI elif 201 < resultAQI <= 300: colorAQI = 'Violet' return colorAQI else: colorAQI = 'Black' return colorAQI