Spaces:
Running
Running
Update pages/community.py
Browse files- pages/community.py +45 -15
pages/community.py
CHANGED
@@ -1,22 +1,52 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
21 |
|
22 |
-
|
|
|
1 |
import gradio as gr
|
2 |
+
import requests
|
3 |
+
import json
|
4 |
|
5 |
+
SUPABASE_URL = "https://fpbuhzbdtzwomjwytqul.supabase.co"
|
6 |
+
SUPABASE_API_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImZwYnVoemJkdHp3b21qd3l0cXVsIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTE5NDk3NzYsImV4cCI6MjA2NzUyNTc3Nn0.oAa2TNNPQMyOGk63AOMZ7XKcwYvy5m-xoSWyvMZd6FY"
|
7 |
+
SUPABASE_FEEDBACK_TABLE = "feedback"
|
8 |
+
|
9 |
+
headers = {
|
10 |
+
"apikey": SUPABASE_API_KEY,
|
11 |
+
"Authorization": f"Bearer {SUPABASE_API_KEY}",
|
12 |
+
"Content-Type": "application/json"
|
13 |
+
}
|
14 |
|
15 |
+
def submit_feedback(name, email, rating, comments):
|
16 |
+
if not all([name, email, rating, comments]):
|
17 |
+
return "β Please fill in all fields before submitting."
|
18 |
+
|
19 |
+
data = {
|
20 |
+
"name": name,
|
21 |
+
"email": email,
|
22 |
+
"rating": int(rating),
|
23 |
+
"comments": comments
|
24 |
+
}
|
25 |
|
26 |
+
response = requests.post(
|
27 |
+
f"{SUPABASE_URL}/rest/v1/{SUPABASE_FEEDBACK_TABLE}",
|
28 |
+
headers=headers,
|
29 |
+
data=json.dumps(data)
|
30 |
+
)
|
31 |
|
32 |
+
if response.status_code == 201:
|
33 |
+
return "β
Thank you for your feedback!"
|
34 |
+
else:
|
35 |
+
return f"β Failed to submit feedback. Error: {response.text}"
|
36 |
+
|
37 |
+
def layout():
|
38 |
+
with gr.Column():
|
39 |
+
gr.Markdown("## π Community & Feedback")
|
40 |
+
gr.Markdown("""
|
41 |
+
Welcome to the VerifiAI community hub!
|
42 |
+
We'd love to hear your feedback to improve this tool.
|
43 |
+
""")
|
44 |
|
45 |
+
name = gr.Textbox(label="Your Name")
|
46 |
+
email = gr.Textbox(label="Email")
|
47 |
+
rating = gr.Slider(minimum=1, maximum=5, step=1, label="Rating (1 to 5)")
|
48 |
+
comments = gr.Textbox(label="Your Comments", lines=4, placeholder="What do you like? What can be improved?")
|
49 |
+
submit_btn = gr.Button("Submit Feedback", variant="primary")
|
50 |
+
status = gr.Textbox(label="Submission Status", interactive=False)
|
51 |
|
52 |
+
submit_btn.click(fn=submit_feedback, inputs=[name, email, rating, comments], outputs=status)
|