import gradio as gr import pandas as pd import sqlite3 import os import datetime # Paths DB_FILE = "data/teamup.db" os.makedirs("data", exist_ok=True) # Initialize database conn = sqlite3.connect(DB_FILE) c = conn.cursor() c.execute(''' CREATE TABLE IF NOT EXISTS teamup ( discord TEXT PRIMARY KEY, name TEXT, city TEXT, country TEXT, address TEXT, looking TEXT, onlinecheck TEXT, languages TEXT, laptop TEXT, robot TEXT, skills TEXT, describe3 TEXT, experience TEXT, idea TEXT ) ''') conn.commit() conn.close() ADMIN_CODE = os.getenv("ADMIN_CODE", "") ALL_COUNTRIES = sorted(list(set([ "United States of America", "United Kingdom", "India", "France", "Germany", "Canada", "Australia", "Japan", "Brazil", "Mexico", "Afghanistan", "Albania", "Algeria", "Andorra", "Angola", "Argentina", "Armenia", "Austria", "Azerbaijan", "Bangladesh", "Belgium", "Bhutan", "Bolivia", "Bosnia and Herzegovina", "Botswana", "Bulgaria", "Cambodia", "Chile", "China", "Colombia", "Croatia", "Cuba", "Czech Republic", "Denmark", "Dominican Republic", "Ecuador", "Egypt", "Estonia", "Ethiopia", "Finland", "Greece", "Hungary", "Iceland", "Indonesia", "Iran", "Iraq", "Ireland", "Israel", "Italy", "Jordan", "Kenya", "Kuwait", "Latvia", "Lithuania", "Luxembourg", "Malaysia", "Malta", "Morocco", "Nepal", "Netherlands", "New Zealand", "Nigeria", "Norway", "Pakistan", "Peru", "Philippines", "Poland", "Portugal", "Qatar", "Romania", "Russia", "Saudi Arabia", "Serbia", "Singapore", "Slovakia", "Slovenia", "South Africa", "South Korea", "Spain", "Sri Lanka", "Sweden", "Switzerland", "Thailand", "Tunisia", "Turkey", "Ukraine", "United Arab Emirates", "Vietnam", "Zambia", "Zimbabwe" ]))) LANGUAGES = ["English", "French", "Spanish", "German", "Portuguese", "Chinese", "Arabic", "Hindi"] # Insert or update profile def submit_profile(name, discord, city, country, address, looking, onlinecheck, languages, laptop, robot, skills, describe3, experience, idea): if not discord or not city or not country or not laptop or not robot: return "❌ Please fill in all required fields." lang_str = ", ".join(languages) if isinstance(languages, list) else languages conn = sqlite3.connect(DB_FILE) c = conn.cursor() c.execute(""" INSERT INTO teamup (discord, name, city, country, address, looking, onlinecheck, languages, laptop, robot, skills, describe3, experience, idea) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ON CONFLICT(discord) DO UPDATE SET name=excluded.name, city=excluded.city, country=excluded.country, address=excluded.address, looking=excluded.looking, onlinecheck=excluded.onlinecheck, languages=excluded.languages, laptop=excluded.laptop, robot=excluded.robot, skills=excluded.skills, describe3=excluded.describe3, experience=excluded.experience, idea=excluded.idea """, (discord, name, city.title(), country.title(), address, looking, onlinecheck, lang_str.lower(), laptop, robot, skills, describe3, experience, idea)) conn.commit() conn.close() return "✅ Profile saved!" # Filter and return HTML table def filter_by_fields(selected_country, selected_city, selected_language): conn = sqlite3.connect(DB_FILE) df = pd.read_sql_query("SELECT * FROM teamup", conn) conn.close() if df.empty: return "
No data available.
" df["City"] = df["city"].str.title() df["Country"] = df["country"].str.title() df["Languages"] = df["languages"] if selected_country != "All": df = df[df["Country"] == selected_country.title()] if selected_city != "All": df = df[df["City"] == selected_city.title()] if selected_language != "All": df = df[df["Languages"].str.contains(selected_language.lower(), na=False)] if df.empty: return "No participants match your filters.
" html = "| {col} | " html += "
|---|
| {val} | " html += "