Spaces:
Sleeping
Sleeping
Update pages/community.py
Browse files- 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 "β
|
18 |
-
|
19 |
data = {
|
20 |
"name": name,
|
21 |
"email": email,
|
22 |
-
"rating":
|
23 |
-
"comments": comments
|
|
|
24 |
}
|
25 |
|
26 |
response = requests.post(
|
27 |
-
f"{SUPABASE_URL}/rest/v1/
|
28 |
headers=headers,
|
29 |
data=json.dumps(data)
|
30 |
)
|
31 |
|
32 |
if response.status_code == 201:
|
33 |
-
return
|
|
|
|
|
|
|
34 |
else:
|
35 |
-
return
|
|
|
|
|
|
|
36 |
|
37 |
def layout():
|
38 |
with gr.Column():
|
39 |
-
gr.Markdown("## π
|
|
|
40 |
gr.Markdown("""
|
41 |
-
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
""")
|
44 |
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
|
52 |
-
submit_btn.click(
|
|
|
|
|
|
|
|
|
|
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 |
+
)
|