File size: 589 Bytes
1a82b85
6bf3a48
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1a82b85
c554d38
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import gradio as gr
import os

def test_load():
    files = os.listdir(".")
    if "genealogy.txt" not in files:
        return f"❌ 文件缺失!当前目录文件: {files}"
    try:
        with open("genealogy.txt", "r", encoding="utf-8") as f:
            lines = f.readlines()
        return f"✅ 成功读取 {len(lines)} 行"
    except Exception as e:
        return f"❌ 读取失败: {str(e)}"

with gr.Blocks() as demo:
    gr.Markdown("# 调试模式")
    btn = gr.Button("检查 genealogy.txt")
    out = gr.Textbox()
    btn.click(test_load, outputs=out)

demo.launch()