Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,21 @@
|
|
| 1 |
-
# app.py - 最小可运行示例
|
| 2 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
-
demo = gr.Interface(fn=lambda x: f"Hello, {x}!", inputs="text", outputs="text")
|
| 5 |
demo.launch()
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
def test_load():
|
| 5 |
+
files = os.listdir(".")
|
| 6 |
+
if "genealogy.txt" not in files:
|
| 7 |
+
return f"❌ 文件缺失!当前目录文件: {files}"
|
| 8 |
+
try:
|
| 9 |
+
with open("genealogy.txt", "r", encoding="utf-8") as f:
|
| 10 |
+
lines = f.readlines()
|
| 11 |
+
return f"✅ 成功读取 {len(lines)} 行"
|
| 12 |
+
except Exception as e:
|
| 13 |
+
return f"❌ 读取失败: {str(e)}"
|
| 14 |
+
|
| 15 |
+
with gr.Blocks() as demo:
|
| 16 |
+
gr.Markdown("# 调试模式")
|
| 17 |
+
btn = gr.Button("检查 genealogy.txt")
|
| 18 |
+
out = gr.Textbox()
|
| 19 |
+
btn.click(test_load, outputs=out)
|
| 20 |
|
|
|
|
| 21 |
demo.launch()
|