Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,28 +1,37 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
class GUI:
|
4 |
def __init__(self):
|
5 |
with gr.Blocks() as demo:
|
6 |
-
with gr.Row():
|
7 |
-
gr.LoginButton()
|
8 |
-
self.l_o_btn = gr.LogoutButton(visible=False)
|
9 |
-
self.inp = gr.File(file_types=['.epub'], visible=False)
|
10 |
self.out = gr.Markdown().attach_load_event(self.hello, None)
|
11 |
-
self.inp.change(self.hello, self.inp, self.out)
|
12 |
|
13 |
demo.launch()
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
def greet(self, name):
|
16 |
return "Hello " + name + "!!"
|
17 |
|
18 |
def hello(self, profile: gr.OAuthProfile | None):
|
19 |
if profile is None:
|
|
|
|
|
|
|
20 |
return (
|
21 |
'# ePub summarization tool '
|
22 |
'<p style="text-align: center;">Login to access the tool.</p>'
|
23 |
)
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
|
|
26 |
return self.greet(profile.name)
|
27 |
|
28 |
GUI()
|
|
|
1 |
import gradio as gr
|
2 |
+
from epub2txt import epub2txt
|
3 |
|
4 |
class GUI:
|
5 |
def __init__(self):
|
6 |
with gr.Blocks() as demo:
|
|
|
|
|
|
|
|
|
7 |
self.out = gr.Markdown().attach_load_event(self.hello, None)
|
|
|
8 |
|
9 |
demo.launch()
|
10 |
|
11 |
+
def process(self, file):
|
12 |
+
ch_list = epub2txt(file, outputlist=True)
|
13 |
+
chapter_titles = epub2txt.content_titles
|
14 |
+
title = epub2txt.title
|
15 |
+
return f"# {title}\n\n" + "\n\n".join([f"## {ct}\n\n{c}" for ct, c in zip(chapter_titles, ch_list)])
|
16 |
+
|
17 |
def greet(self, name):
|
18 |
return "Hello " + name + "!!"
|
19 |
|
20 |
def hello(self, profile: gr.OAuthProfile | None):
|
21 |
if profile is None:
|
22 |
+
with gr.Blocks(css=".lbtn {float: right;}") as demo:
|
23 |
+
with gr.Row():
|
24 |
+
gr.LoginButton(elem_classes="lbtn")
|
25 |
return (
|
26 |
'# ePub summarization tool '
|
27 |
'<p style="text-align: center;">Login to access the tool.</p>'
|
28 |
)
|
29 |
+
with gr.Blocks(css=".lbtn {float: right;}") as demo:
|
30 |
+
with gr.Row():
|
31 |
+
gr.LoginButton(elem_classes="lbtn")
|
32 |
+
gr.LogoutButton(elem_classes="lbtn")
|
33 |
+
inp = gr.File(file_types=['.epub'])
|
34 |
+
inp.change(self.process, inp, self.out)
|
35 |
return self.greet(profile.name)
|
36 |
|
37 |
GUI()
|