sshtel commited on
Commit
dacc38c
·
1 Parent(s): 8072e03

fix bug of image path traversal

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -66,11 +66,11 @@ for key, (path, dur, mel) in create_sound_library.items():
66
  if not os.path.exists(path):
67
  generate_chimes_wav(path, duration=dur, melody_type=mel)
68
 
69
- COVERS_DIR = Path("assets/covers")
70
 
71
  def cover_path(slug: str) -> str:
72
  p = COVERS_DIR / f"{slug}.png"
73
- return f"/gradio_api/file={p.as_posix()}"
74
 
75
  def load_books_from_stories(stories_dir="stories"):
76
  books = []
@@ -457,7 +457,7 @@ with gr.Blocks(css=css_code, title="VoiceBook Gradio Hub") as demo:
457
 
458
  # Story text display + slider
459
  story_text_display = gr.HTML(visible=False)
460
- timeline_slider = gr.Slider(minimum=0, maximum=0, step=1, value=0, label="📍 Story position (paragraph)", visible=False)
461
 
462
  # Q&A Panel
463
  qa_panel = gr.HTML("""
@@ -922,4 +922,4 @@ with gr.Blocks(css=css_code, title="VoiceBook Gradio Hub") as demo:
922
  offline_toggle.change(toggle_outage_sandbox, inputs=[offline_toggle], outputs=[system_error_modal, main_tabs])
923
 
924
  if __name__ == "__main__":
925
- demo.queue().launch(allowed_paths=["assets"])
 
66
  if not os.path.exists(path):
67
  generate_chimes_wav(path, duration=dur, melody_type=mel)
68
 
69
+ COVERS_DIR = Path(__file__).parent / "assets" / "covers"
70
 
71
  def cover_path(slug: str) -> str:
72
  p = COVERS_DIR / f"{slug}.png"
73
+ return f"/gradio_api/file={p.resolve().as_posix()}"
74
 
75
  def load_books_from_stories(stories_dir="stories"):
76
  books = []
 
457
 
458
  # Story text display + slider
459
  story_text_display = gr.HTML(visible=False)
460
+ timeline_slider = gr.Slider(minimum=0, maximum=100, step=1, value=0, label="📍 Story position (paragraph)", visible=False)
461
 
462
  # Q&A Panel
463
  qa_panel = gr.HTML("""
 
922
  offline_toggle.change(toggle_outage_sandbox, inputs=[offline_toggle], outputs=[system_error_modal, main_tabs])
923
 
924
  if __name__ == "__main__":
925
+ demo.queue().launch(allowed_paths=[str(Path(__file__).parent / "assets")])