Update app.py
Browse files
app.py
CHANGED
|
@@ -29,7 +29,7 @@ def update_table(category):
|
|
| 29 |
def get_user(profile):
|
| 30 |
if profile is None:
|
| 31 |
return "Please log in to see your username."
|
| 32 |
-
return
|
| 33 |
|
| 34 |
|
| 35 |
|
|
@@ -101,8 +101,10 @@ with gr.Blocks() as app:
|
|
| 101 |
# else:
|
| 102 |
# login_button = gr.LoginButton()
|
| 103 |
|
| 104 |
-
|
| 105 |
-
gr.
|
|
|
|
|
|
|
| 106 |
category = gr.Dropdown(
|
| 107 |
choices=["Biology", "Physics", "Business", "Chemistry", "Economics", "Philosophy", "History", "Culture", "Computer Science", "Math", "Health", "Law", "Engineering", "Other"],
|
| 108 |
label="Select Category"
|
|
@@ -110,10 +112,7 @@ with gr.Blocks() as app:
|
|
| 110 |
vote = gr.CheckboxGroup(choices=["Option 1", "Option 2", "Option 3"], label="Choose your options")
|
| 111 |
submit_button = gr.Button("Submit Vote")
|
| 112 |
submit_result = gr.Label()
|
| 113 |
-
|
| 114 |
-
submit_button.click(fn=submit_vote, inputs=[username_text, category, vote], outputs=submit_result)
|
| 115 |
-
else:
|
| 116 |
-
submit_button.click(fn=lambda: "Please log in to submit your vote.", inputs=[], outputs=submit_result)
|
| 117 |
|
| 118 |
|
| 119 |
# with gr.TabItem("Submit Model"):
|
|
|
|
| 29 |
def get_user(profile):
|
| 30 |
if profile is None:
|
| 31 |
return "Please log in to see your username."
|
| 32 |
+
return {profile.username}
|
| 33 |
|
| 34 |
|
| 35 |
|
|
|
|
| 101 |
# else:
|
| 102 |
# login_button = gr.LoginButton()
|
| 103 |
|
| 104 |
+
login_button = gr.LoginButton()
|
| 105 |
+
username_text = gr.Variable(value="Please log in to see your username.") # 这里使用Variable来存储用户名
|
| 106 |
+
login_button.output(username_text, fn=get_user)
|
| 107 |
+
|
| 108 |
category = gr.Dropdown(
|
| 109 |
choices=["Biology", "Physics", "Business", "Chemistry", "Economics", "Philosophy", "History", "Culture", "Computer Science", "Math", "Health", "Law", "Engineering", "Other"],
|
| 110 |
label="Select Category"
|
|
|
|
| 112 |
vote = gr.CheckboxGroup(choices=["Option 1", "Option 2", "Option 3"], label="Choose your options")
|
| 113 |
submit_button = gr.Button("Submit Vote")
|
| 114 |
submit_result = gr.Label()
|
| 115 |
+
submit_button.click(fn=submit_vote, inputs=[username_text, category, votes], outputs=submit_result)
|
|
|
|
|
|
|
|
|
|
| 116 |
|
| 117 |
|
| 118 |
# with gr.TabItem("Submit Model"):
|