Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- app.py +23 -0
- requirements.txt +0 -0
app.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import pandas as pd
|
3 |
+
import random
|
4 |
+
|
5 |
+
def random_excel_viewer(excel_file):
|
6 |
+
df = pd.read_excel(excel_file.name)
|
7 |
+
column_name = df.columns[0]
|
8 |
+
random_entry = random.choice(df[column_name])
|
9 |
+
return f"被随机的幸运观众:\n{random_entry}"
|
10 |
+
|
11 |
+
iface = gr.Interface(
|
12 |
+
fn=random_excel_viewer,
|
13 |
+
inputs="file",
|
14 |
+
outputs="text",
|
15 |
+
layout="vertical",
|
16 |
+
title="课堂开心点名器",
|
17 |
+
description="随机抽取一名幸运观众。"
|
18 |
+
)
|
19 |
+
|
20 |
+
iface.launch()
|
21 |
+
|
22 |
+
# 运行主循环
|
23 |
+
root.mainloop()
|
requirements.txt
ADDED
Binary file (2.21 kB). View file
|
|