fzd13 / app.py
fdbw's picture
Update app.py
6bf3a48 verified
Raw
History Blame Contribute Delete
589 Bytes
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()