parass13 commited on
Commit
e5dd0a4
Β·
verified Β·
1 Parent(s): fa4be61

Update pages/community.py

Browse files
Files changed (1) hide show
  1. pages/community.py +46 -18
pages/community.py CHANGED
@@ -1,10 +1,10 @@
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,
@@ -14,39 +14,67 @@ headers = {
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)
 
 
 
 
 
1
  import gradio as gr
2
  import requests
3
  import json
4
+ import datetime
5
 
6
  SUPABASE_URL = "https://fpbuhzbdtzwomjwytqul.supabase.co"
7
  SUPABASE_API_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImZwYnVoemJkdHp3b21qd3l0cXVsIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTE5NDk3NzYsImV4cCI6MjA2NzUyNTc3Nn0.oAa2TNNPQMyOGk63AOMZ7XKcwYvy5m-xoSWyvMZd6FY"
 
8
 
9
  headers = {
10
  "apikey": SUPABASE_API_KEY,
 
14
 
15
  def submit_feedback(name, email, rating, comments):
16
  if not all([name, email, rating, comments]):
17
+ return "❌ All fields are required.", name, email, rating, comments
18
+
19
  data = {
20
  "name": name,
21
  "email": email,
22
+ "rating": rating,
23
+ "comments": comments,
24
+ "submitted": datetime.datetime.now().isoformat()
25
  }
26
 
27
  response = requests.post(
28
+ f"{SUPABASE_URL}/rest/v1/feedback",
29
  headers=headers,
30
  data=json.dumps(data)
31
  )
32
 
33
  if response.status_code == 201:
34
+ return (
35
+ "βœ… Feedback submitted successfully!",
36
+ "", "", 3, "" # Reset form fields
37
+ )
38
  else:
39
+ return (
40
+ "❌ Failed to submit feedback. Please try again.",
41
+ name, email, rating, comments
42
+ )
43
 
44
  def layout():
45
  with gr.Column():
46
+ gr.Markdown("## 🌐 Join the Community")
47
+
48
  gr.Markdown("""
49
+ Deepfakes are becoming increasingly sophisticated. We believe that fighting misinformation is a community effort.
50
+
51
+ ### 🀝 How You Can Contribute
52
+ - **Share your feedback** on the tool’s performance
53
+ - **Report suspicious media** or share verified datasets
54
+ - **Suggest improvements** to the detection model
55
+ - **Educate others** on recognizing and avoiding deepfake scams
56
+
57
+ ### πŸ’¬ Let’s Talk
58
+ Join our open discussions and connect with developers, researchers, and digital safety advocates.
59
+ Whether you're a student, developer, or just curious β€” your voice matters.
60
  """)
61
 
62
+ gr.Markdown("### πŸ“ Submit Feedback")
63
+
64
+ with gr.Row():
65
+ name = gr.Textbox(label="Name")
66
+ email = gr.Textbox(label="Email")
67
+
68
+ with gr.Row():
69
+ rating = gr.Slider(minimum=1, maximum=5, step=1, value=3, label="Rating", interactive=True)
70
+
71
+ comments = gr.Textbox(label="Comments", lines=3, max_lines=4, placeholder="Let us know what you think...")
72
+
73
+ submit_btn = gr.Button("Submit", variant="primary")
74
+ response_msg = gr.Markdown("")
75
 
76
+ submit_btn.click(
77
+ fn=submit_feedback,
78
+ inputs=[name, email, rating, comments],
79
+ outputs=[response_msg, name, email, rating, comments]
80
+ )