Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import os
|
3 |
+
import json
|
4 |
+
import collections
|
5 |
+
from pyrebase import pyrebase
|
6 |
+
config = {
|
7 |
+
"apiKey": os.environ.get("key"),
|
8 |
+
"authDomain": os.environ.get("domain"),
|
9 |
+
"databaseURL": os.environ.get("url"),
|
10 |
+
"projectId": os.environ.get("id"),
|
11 |
+
"storageBucket": os.environ.get("st_bk"),
|
12 |
+
"messagingSenderId": os.environ.get("sn_id"),
|
13 |
+
"appId": os.environ.get("a_id")
|
14 |
+
}
|
15 |
+
|
16 |
+
app = pyrebase.initialize_app(config)
|
17 |
+
db = app.database()
|
18 |
+
|
19 |
+
def function(parameter):
|
20 |
+
data = db.child("Data").child(parameter).get()
|
21 |
+
data = data.val()
|
22 |
+
if isinstance(data, collections.OrderedDict):
|
23 |
+
data = json.dumps(data)
|
24 |
+
return data
|
25 |
+
else:
|
26 |
+
return data
|
27 |
+
|
28 |
+
iface = gr.Interface(fn=function, inputs="text", outputs="text")
|
29 |
+
iface.launch()
|