ysharma HF Staff commited on
Commit
b4f925b
Β·
verified Β·
1 Parent(s): dd2f7ab

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +225 -0
app.py ADDED
@@ -0,0 +1,225 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import pandas as pd
3
+ from datasets import load_dataset
4
+ from huggingface_hub import login
5
+ import os
6
+ import logging
7
+
8
+ # Setup logging
9
+ logging.basicConfig(level=logging.INFO)
10
+ logger = logging.getLogger(__name__)
11
+
12
+ # Authenticate with Hugging Face
13
+ HF_TOKEN = os.environ.get("HF_TOKEN")
14
+ if HF_TOKEN:
15
+ login(token=HF_TOKEN)
16
+ logger.info("βœ… Authenticated with Hugging Face")
17
+ else:
18
+ logger.warning("⚠️ HF_TOKEN not found - running without authentication")
19
+
20
+ # Dataset name
21
+ DATASET_NAME = "ysharma/gradio-hackathon-registrations-winter-2025"
22
+
23
+ def verify_registration(email, hf_username):
24
+ """
25
+ Verify if a user is registered by checking both email and HF username
26
+ Returns registration details if both match
27
+ """
28
+ try:
29
+ # Validate inputs
30
+ if not email or not email.strip():
31
+ return "❌ Please enter your email address"
32
+
33
+ if not hf_username or not hf_username.strip():
34
+ return "❌ Please enter your Hugging Face username"
35
+
36
+ logger.info(f"Verification attempt for email: {email}")
37
+
38
+ # Load dataset
39
+ try:
40
+ dataset = load_dataset(DATASET_NAME, split="train")
41
+ df = dataset.to_pandas()
42
+ logger.info(f"Loaded dataset with {len(df)} registrations")
43
+ except Exception as load_error:
44
+ logger.error(f"Failed to load dataset: {load_error}")
45
+ return "❌ Unable to verify registration at this time. Please try again later."
46
+
47
+ # Search for exact match (both email AND username must match)
48
+ email_lower = email.strip().lower()
49
+ username_lower = hf_username.strip().lower()
50
+
51
+ match = df[
52
+ (df['email'].str.lower() == email_lower) &
53
+ (df['hf_username'].str.lower() == username_lower)
54
+ ]
55
+
56
+ if len(match) == 0:
57
+ # Check if email exists with different username
58
+ email_exists = df[df['email'].str.lower() == email_lower]
59
+ username_exists = df[df['hf_username'].str.lower() == username_lower]
60
+
61
+ if len(email_exists) > 0 and len(username_exists) == 0:
62
+ return "❌ Email found but Hugging Face username doesn't match. Please check your username."
63
+ elif len(username_exists) > 0 and len(email_exists) == 0:
64
+ return "❌ Hugging Face username found but email doesn't match. Please check your email."
65
+ else:
66
+ return "❌ No registration found with this email and Hugging Face username combination."
67
+
68
+ # Registration found - format the details
69
+ registration = match.iloc[0]
70
+
71
+ # Parse timestamp
72
+ try:
73
+ timestamp = pd.to_datetime(registration['timestamp'])
74
+ reg_date = timestamp.strftime("%B %d, %Y at %I:%M %p UTC")
75
+ except:
76
+ reg_date = registration['timestamp']
77
+
78
+ # Format track interests
79
+ track_interest = registration['track_interest']
80
+ if isinstance(track_interest, str):
81
+ # Clean up the string representation of list
82
+ track_interest = track_interest.strip("[]'\"").replace("'", "")
83
+
84
+ result = f"""
85
+ ## βœ… Registration Confirmed!
86
+
87
+ **Participant Details:**
88
+ - **Full Name:** {registration['full_name']}
89
+ - **Email:** {registration['email']}
90
+ - **Hugging Face Username:** {registration['hf_username']}
91
+ - **Registered On:** {reg_date}
92
+
93
+ **Hackathon Participation:**
94
+ - **Track Interest:** {track_interest}
95
+ - **Gradio Usage:** {registration['gradio_usage']}
96
+ - **Previous Participation:** {registration['previous_participation']}
97
+ - **Experience Level:** {registration['experience_level']}
98
+ - **How You Heard:** {registration['how_heard']}
99
+
100
+ **Project Idea:**
101
+ {registration['project_description'] if registration['project_description'] else '_No project description provided_'}
102
+
103
+ ---
104
+
105
+ **Next Steps:**
106
+ - πŸ”‘ API and Compute credits will be distributed before or during the hackathon
107
+ - πŸ’¬ Join our Discord community channel `mcp-1st-birthday-officialπŸ†`: https://discord.gg/92sEPT2Zhv
108
+ - πŸ“§ Watch your email for important updates
109
+ - πŸš€ Start planning your project!
110
+ """
111
+
112
+ logger.info(f"βœ… Verification successful for {email}")
113
+ return result
114
+
115
+ except Exception as e:
116
+ logger.error(f"Error during verification: {e}")
117
+ import traceback
118
+ traceback.print_exc()
119
+ return f"❌ An error occurred during verification: {str(e)}"
120
+
121
+ # Custom CSS for MCP theme
122
+ custom_css = """
123
+ .gradio-container {
124
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
125
+ }
126
+
127
+ /* Verify button styling - MCP theme */
128
+ #verify-btn {
129
+ background: #C8DDD7 !important;
130
+ border: 2px solid #000000 !important;
131
+ color: #000000 !important;
132
+ font-weight: 600 !important;
133
+ font-size: 18px !important;
134
+ padding: 16px 32px !important;
135
+ border-radius: 12px !important;
136
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
137
+ transition: all 0.3s ease !important;
138
+ }
139
+
140
+ #verify-btn:hover {
141
+ transform: translateY(-2px) !important;
142
+ box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25) !important;
143
+ background: #B8CEC7 !important;
144
+ }
145
+
146
+ #verify-btn:active {
147
+ transform: translateY(0px) !important;
148
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2) !important;
149
+ }
150
+ """
151
+
152
+ # Create the Gradio interface
153
+ with gr.Blocks(title="MCP Birthday Party - Registration Verification", css=custom_css, theme="ocean") as demo:
154
+
155
+ # Header
156
+ gr.Markdown("""
157
+ # πŸ” MCP's 1st Birthday - Registration Verification
158
+
159
+ **Verify your registration for the Gradio Agents & MCP Hackathon**
160
+
161
+ **πŸ“… Event Dates:** November 14-30, 2025 | **πŸ† Prizes: $17,000+ USD**
162
+
163
+ Enter your email address and Hugging Face username to verify your registration and view your details.
164
+ """)
165
+
166
+ gr.Markdown("---")
167
+
168
+ with gr.Row():
169
+ with gr.Column():
170
+ verify_email = gr.Textbox(
171
+ label="Email Address",
172
+ placeholder="Enter your registered email",
173
+ max_lines=1
174
+ )
175
+
176
+ verify_hf_username = gr.Textbox(
177
+ label="Hugging Face Username",
178
+ placeholder="Enter your registered HF username",
179
+ max_lines=1
180
+ )
181
+
182
+ verify_btn = gr.Button("πŸ” Check Registration Status", variant="primary", size="lg", elem_id="verify-btn")
183
+
184
+ with gr.Column():
185
+ gr.Markdown("""
186
+ ### Important Notes
187
+
188
+ - Make sure you enter the **exact** email and username you used during registration
189
+ - Both fields are **case-insensitive** but must match your registration
190
+ - Both email AND username must match for security purposes
191
+ - If you can't find your registration, try registering at the main hackathon page
192
+
193
+ ### Need Help?
194
+
195
+ - **Discord:** https://discord.gg/92sEPT2Zhv (channel: `mcp-1st-birthday-officialπŸ†`)
196
+ - **Email:** [email protected]
197
+ - **Register:** [Main Registration Page](https://huggingface.co/spaces/ysharma/gradio-mcp-1st-birthday-hackathon-winter-2025)
198
+ """)
199
+
200
+ verify_output = gr.Markdown()
201
+
202
+ # Verification click event
203
+ verify_btn.click(
204
+ fn=verify_registration,
205
+ inputs=[verify_email, verify_hf_username],
206
+ outputs=verify_output
207
+ )
208
+
209
+ # Footer
210
+ gr.Markdown("""
211
+ ---
212
+
213
+ **🎯 About the Hackathon:**
214
+
215
+ Join the definitive Agents & MCP event! OpenAI, Microsoft, Google DeepMind, and numerous startups have already adopted MCP.
216
+ Participate and stand a chance to learn the latest AI technologies and Win BIG!
217
+
218
+ **πŸ”— Quick Links:**
219
+ - [Main Registration Page](https://huggingface.co/spaces/ysharma/gradio-mcp-1st-birthday-hackathon-winter-2025)
220
+ - [Discord Community](https://discord.gg/92sEPT2Zhv)
221
+ - [Hackathon Details & Rules](https://huggingface.co/mcphack)
222
+ """)
223
+
224
+ if __name__ == "__main__":
225
+ demo.launch()