Corin1998 commited on
Commit
5621a82
·
verified ·
1 Parent(s): d13b751

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -5
app.py CHANGED
@@ -4,15 +4,22 @@ import time
4
  import sys
5
  import gradio as gr
6
 
7
- # --- add: make sure we can import from ./modules even if it's not a package
8
  BASE_DIR = os.path.dirname(os.path.abspath(__file__))
9
  MODULES_DIR = os.path.join(BASE_DIR, "modules")
10
- if MODULES_DIR not in sys.path:
11
  sys.path.insert(0, MODULES_DIR)
12
 
13
- from text_processing import process_text
14
- from pptx_builder import build_presentation
15
- from utils import safe_hex_to_rgb, ensure_tmpdir
 
 
 
 
 
 
 
16
 
17
  APP_NAME = "Auto-PPT Generator"
18
 
 
4
  import sys
5
  import gradio as gr
6
 
7
+ # --- Ensure we can import modules whether it's a package or a plain folder ---
8
  BASE_DIR = os.path.dirname(os.path.abspath(__file__))
9
  MODULES_DIR = os.path.join(BASE_DIR, "modules")
10
+ if os.path.isdir(MODULES_DIR) and MODULES_DIR not in sys.path:
11
  sys.path.insert(0, MODULES_DIR)
12
 
13
+ try:
14
+ # Prefer package-style if modules/__init__.py exists
15
+ from modules.text_processing import process_text
16
+ from modules.pptx_builder import build_presentation
17
+ from modules.utils import safe_hex_to_rgb, ensure_tmpdir
18
+ except ModuleNotFoundError:
19
+ # Fallback: flat imports from ./modules added to sys.path
20
+ from text_processing import process_text
21
+ from pptx_builder import build_presentation
22
+ from utils import safe_hex_to_rgb, ensure_tmpdir
23
 
24
  APP_NAME = "Auto-PPT Generator"
25