scottire commited on
Commit
f510ec2
·
1 Parent(s): 55f1b51

pokemon image

Browse files
Files changed (1) hide show
  1. app.py +12 -3
app.py CHANGED
@@ -1,7 +1,16 @@
 
 
 
1
  import gradio as gr
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
 
 
 
 
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
  iface.launch()
 
1
+ import requests
2
+ from PIL import Image
3
+ import io
4
  import gradio as gr
5
 
6
+ def get_image(pokemon_name):
7
+ response = requests.get(f'https://pokeapi.co/api/v2/pokemon/{pokemon_name}')
8
+ data = response.json()
9
+ image_url = data['sprites']['other']['official-artwork']['front_default']
10
+
11
+ image_response = requests.get(image_url)
12
+ image = Image.open(io.BytesIO(image_response.content))
13
+ return image
14
 
15
+ iface = gr.Interface(fn=get_image, inputs="text", outputs="image")
16
  iface.launch()