Arigadam commited on
Commit
81c69a0
1 Parent(s): 53cad13

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import requests
3
+
4
+ url = "https://scp-294-api-ru.p.rapidapi.com/v1/drink"
5
+
6
+ def func(api_key, query):
7
+ headers = {
8
+ "X-RapidAPI-Key": api_key,
9
+ "X-RapidAPI-Host": "scp-294-api-ru.p.rapidapi.com"
10
+ }
11
+ querystring = {"name":query}
12
+ answer = requests.get(url, headers=headers, params=querystring).json()
13
+ html = """<div style="height: 50px; width: 50px; background-color: %s;"></div><br>
14
+ <p>урон: %s</p><br>
15
+ <p>добавка к скорости: %s</p><br>
16
+ <p>описание:<br>%s</p>
17
+ """ % (answer["color"], str(answer["damage"]), str(answer["speed"]), answer["description"])
18
+ return html
19
+
20
+ with gr.Blocks() as app:
21
+ gr.Markdown("# SCP-294")
22
+ gr.Markdown("Пожалуйста, получите свой API ключ [здесь](https://rapidapi.com/oficalkapudovo/api/scp-294-api-ru)")
23
+ gr.Markdown("Первое поле - для ключа, второе - для запроса")
24
+ gr.Interface(fn=func, inputs=["text", "text"], outputs="html")
25
+ gr.HTML("<small>Сделано Arigadam'ом</small>")
26
+
27
+ app.launch(share=True, debug=True)