npc0 commited on
Commit
f5f74ce
1 Parent(s): b2f14ff

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -10
app.py CHANGED
@@ -5,9 +5,10 @@ class GUI:
5
  def __init__(self, *args, **kwargs):
6
  with gr.Blocks() as demo:
7
  with gr.Row():
8
- self.out = gr.Markdown(scale=2).attach_load_event(self.hello, None)
9
  gr.LoginButton()
10
  gr.LogoutButton()
 
11
  inp = gr.File(file_types=['.epub'])
12
  inp.change(self.process, inp, self.out)
13
  demo.launch()
@@ -16,19 +17,13 @@ class GUI:
16
  ch_list = epub2txt(file.name, outputlist=True)
17
  chapter_titles = epub2txt.content_titles
18
  title = epub2txt.title
19
- return gr.Update(
20
  f"# {title}\n\n" + "\n\n".join(
21
  [f"## {ct}\n\n{c}" for ct, c in zip(chapter_titles, ch_list)]))
22
 
23
- def greet(self, name):
24
- return "Hello " + name + "!!"
25
-
26
  def hello(self, profile: gr.OAuthProfile | None):
27
  if profile is None:
28
- return (
29
- '# ePub summarization tool '
30
- '<p style="text-align: center;">Login to access the tool.</p>'
31
- )
32
- return self.greet(profile.name)
33
 
34
  GUI()
 
5
  def __init__(self, *args, **kwargs):
6
  with gr.Blocks() as demo:
7
  with gr.Row():
8
+ gr.Markdown(scale=2).attach_load_event(self.hello, None)
9
  gr.LoginButton()
10
  gr.LogoutButton()
11
+ self.out = gr.Markdown()
12
  inp = gr.File(file_types=['.epub'])
13
  inp.change(self.process, inp, self.out)
14
  demo.launch()
 
17
  ch_list = epub2txt(file.name, outputlist=True)
18
  chapter_titles = epub2txt.content_titles
19
  title = epub2txt.title
20
+ return gr.update(
21
  f"# {title}\n\n" + "\n\n".join(
22
  [f"## {ct}\n\n{c}" for ct, c in zip(chapter_titles, ch_list)]))
23
 
 
 
 
24
  def hello(self, profile: gr.OAuthProfile | None):
25
  if profile is None:
26
+ return '# ePub summarization tool\n\nLogin to access the tool.'
27
+ return f"# ePub summarization tool\n\nWelcome {profile.name}!!"
 
 
 
28
 
29
  GUI()