File size: 794 Bytes
5ae5dcd
 
 
 
 
 
cf85d3b
 
 
 
 
5ae5dcd
 
cf85d3b
 
 
95e6d1e
cf85d3b
95e6d1e
cf85d3b
95e6d1e
cf85d3b
 
 
5ae5dcd
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import gradio as gr
import json
from pathlib import Path

fileid2json = json.loads(Path("fileid2json.json").read_text())

autov22fileid = json.loads(Path("autov22fileid.json").read_text())
filename2fileid = json.loads(Path("filename2fileid.json").read_text())
name2fileid = json.loads(Path("name2fileid.json").read_text())
 

def greet(query):
    result = "Not found"
    fileid = query

    if query in autov22fileid:
        fileid = str(autov22fileid[query])
    if query in filename2fileid:
        fileid = str(filename2fileid[query])
    if query in name2fileid:
        fileid = str(name2fileid[query])

    if fileid in fileid2json:
        result = json.dumps(fileid2json[query.strip()])
    return result

iface = gr.Interface(fn=greet, inputs="text", outputs="text")
iface.launch()