Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,6 +16,7 @@ import PIL.Image
|
|
| 16 |
import PIL.ImageDraw
|
| 17 |
import PIL.ImageFont
|
| 18 |
import gradio as gr
|
|
|
|
| 19 |
|
| 20 |
|
| 21 |
logger = structlog.getLogger()
|
|
@@ -90,6 +91,7 @@ class Weather:
|
|
| 90 |
headers = {'accept': 'application/json'}
|
| 91 |
return requests.get(url, headers=headers).json()
|
| 92 |
|
|
|
|
| 93 |
def get_info(self):
|
| 94 |
weather = self.get_weather()
|
| 95 |
curr_hour = None
|
|
@@ -209,7 +211,7 @@ Do not include specific numbers.'''.replace('\n', ' '))
|
|
| 209 |
# Define Gradio interface
|
| 210 |
iface = gr.Interface(fn=WeatherDraw().step,
|
| 211 |
inputs=gr.inputs.Textbox(label="Enter Zipcode"),
|
| 212 |
-
outputs=[gr.outputs.Image(), "text", "text", "text", "text"],
|
| 213 |
title="US Zipcode Weather",
|
| 214 |
description="Enter a US Zipcode and get some weather.")
|
| 215 |
|
|
|
|
| 16 |
import PIL.ImageDraw
|
| 17 |
import PIL.ImageFont
|
| 18 |
import gradio as gr
|
| 19 |
+
import cachetools.func
|
| 20 |
|
| 21 |
|
| 22 |
logger = structlog.getLogger()
|
|
|
|
| 91 |
headers = {'accept': 'application/json'}
|
| 92 |
return requests.get(url, headers=headers).json()
|
| 93 |
|
| 94 |
+
@cachetools.func.ttl_cache(maxsize=128, ttl=15*60)
|
| 95 |
def get_info(self):
|
| 96 |
weather = self.get_weather()
|
| 97 |
curr_hour = None
|
|
|
|
| 211 |
# Define Gradio interface
|
| 212 |
iface = gr.Interface(fn=WeatherDraw().step,
|
| 213 |
inputs=gr.inputs.Textbox(label="Enter Zipcode"),
|
| 214 |
+
outputs=[gr.outputs.Image(type='pil'), "text", "text", "text", "text"],
|
| 215 |
title="US Zipcode Weather",
|
| 216 |
description="Enter a US Zipcode and get some weather.")
|
| 217 |
|