File size: 1,254 Bytes
c2f1466
 
 
cf7a07e
5aca742
b0d9242
 
 
a7feab8
7192ffe
da9b438
c2f1466
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c2bc0a6
8c634b2
 
 
 
 
 
5be15aa
d79f686
b30a539
c2bc0a6
b30a539
5be15aa
c2bc0a6
8c634b2
 
c2bc0a6
1979413
8c634b2
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import gradio as gr
from gradio import routes
from typing import List, Type

import requests, os, re, asyncio, queue
import math
import time
import datetime
import requests, json

loop = asyncio.get_event_loop()
# Monkey patch
def get_types(cls_set: List[Type], component: str):
    docset = []
    types = []
    if component == "input":
        for cls in cls_set:
            doc = inspect.getdoc(cls)
            doc_lines = doc.split("\n")
            docset.append(doc_lines[1].split(":")[-1])
            types.append(doc_lines[1].split(")")[0].split("(")[-1])
    else:
        for cls in cls_set:
            doc = inspect.getdoc(cls)
            doc_lines = doc.split("\n")
            docset.append(doc_lines[-1].split(":")[-1])
            types.append(doc_lines[-1].split(")")[0].split("(")[-1])
    return docset, types
routes.get_types = get_types

def example_func(id, pw):
    if not id in user_data:
        user_data[id] = pw
        return "ok"
    else:
        return "fail"

with gr.Blocks() as demo:
    count = 0
    gr.Markdown(
    f"sample app"
    )
    aa = gr.Interface(
      fn=example_func,
      inputs=["text", "text"],
      outputs="text",
      description="example_func",
    )
    demo.queue(max_size=32).launch()