File size: 874 Bytes
615f98d
 
ffab851
571c49b
ffab851
 
 
 
 
 
 
 
 
615f98d
ffab851
 
615f98d
ffab851
 
 
 
 
 
 
 
 
caf9c68
 
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
import gradio as gr

class GUI:
    def __init__(self):
        with gr.Blocks() as demo:
            with gr.Row():
                gr.LoginButton()
                self.l_o_btn = gr.LogoutButton(visible=False)
            self.inp = gr.File(file_types=['.epub'], visible=False)
            self.out = gr.Markdown().attach_load_event(self.hello, None)
            inp.change(self.hello, self.inp, self.out)
        
        demo.launch()

    def greet(self, name):
        return "Hello " + name + "!!"

    def hello(self, profile: gr.OAuthProfile | None):
        if profile is None:
            return (
                '# ePub summarization tool  '
                '<p style="text-align: center;">Login to access the tool.</p>'
            )
        self.l_o_btn.update(visible=True)
        self.inp.update(visible=True)
        return self.greet(profile.name)

GUI()