update2 / app.py
tommy24's picture
Update app.py
ab171e7
raw
history blame
770 Bytes
import gradio as gr
import os
import json
import collections
from pyrebase import pyrebase
config = {
"apiKey": os.environ.get("key"),
"authDomain": os.environ.get("domain"),
"databaseURL": os.environ.get("url"),
"projectId": os.environ.get("id"),
"storageBucket": os.environ.get("st_bk"),
"messagingSenderId": os.environ.get("sn_id"),
"appId": os.environ.get("a_id")
}
app = pyrebase.initialize_app(config)
db = app.database()
def function(parameter):
data = db.child("Data").child(parameter).get()
data = data.val()
if isinstance(data, collections.OrderedDict):
data = json.dumps(data)
return data
else:
return data
iface = gr.Interface(fn=function, inputs="text", outputs="text")
iface.launch()