maringetxway commited on
Commit
8a07b68
Β·
verified Β·
1 Parent(s): 7535f90

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -39
app.py CHANGED
@@ -157,47 +157,33 @@ def filter_by_fields(selected_country, selected_city, selected_language):
157
  html += "</table>"
158
  return html
159
 
160
- # Get the list of unique countries from existing data
161
- def get_country_choices():
162
- with open(DATA_FILE, "r") as f:
163
- data = json.load(f)
164
- df = pd.DataFrame(data)
165
-
166
- # Check if 'Country' column exists
167
- if 'Country' in df.columns:
168
- country_choices = sorted(df["Country"].dropna().unique()) # Get unique countries
169
- else:
170
- country_choices = [] # Empty list if no country data is available
171
-
172
- # If no countries are found, you could use a predefined list of countries (optional fallback)
173
- if not country_choices:
174
- country_choices = [
175
- "United States", "Canada", "United Kingdom", "India", "Germany", "France",
176
- "Australia", "Brazil", "Mexico", "Spain", "Italy", "China", "Russia", "Japan"
177
- ]
178
-
179
- return country_choices
 
 
 
180
 
181
  # Function to update the dropdown choices
182
  def update_dropdown_choices():
183
- with open(DATA_FILE, "r") as f:
184
- data = json.load(f)
185
- df = pd.DataFrame(data)
186
-
187
- country_choices = sorted(df["Country"].dropna().unique()) if "Country" in df else []
188
- city_choices = sorted(df["City"].dropna().unique()) if "City" in df else []
189
- language_set = set()
190
- if "Languages" in df:
191
- for lang_list in df["Languages"].dropna():
192
- if isinstance(lang_list, list):
193
- language_set.update(lang_list)
194
- elif isinstance(lang_list, str):
195
- language_set.update(lang_list.split(", "))
196
- return (
197
- gr.update(choices=["All"] + list(country_choices), value="All"),
198
- gr.update(choices=["All"] + list(city_choices), value="All"),
199
- gr.update(choices=["All"] + sorted(language_set), value="All")
200
- )
201
 
202
  # Setup Gradio interface
203
  with gr.Blocks() as demo:
@@ -210,7 +196,7 @@ with gr.Blocks() as demo:
210
  name = gr.Text(label="Name")
211
  discord = gr.Text(label="πŸ‘€ Discord Username *")
212
  city = gr.Text(label="πŸ“ City *")
213
- country = gr.Dropdown(label="🌍 Country *", choices=get_country_choices(), value="All") # Dropdown for Country
214
  address = gr.Text(label="Address (optional)")
215
  looking = gr.Radio(["Yes", "No"], label="πŸ” Looking for a team?")
216
  onlinecheck = gr.Radio(["Participate Online", "Join a Local Hackathon"], label="πŸš€ I will...")
 
157
  html += "</table>"
158
  return html
159
 
160
+ # List of all countries in alphabetical order
161
+ ALL_COUNTRIES = [
162
+ "Afghanistan", "Albania", "Algeria", "Andorra", "Angola", "Antigua and Barbuda", "Argentina", "Armenia", "Australia", "Austria",
163
+ "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bhutan",
164
+ "Bolivia", "Bosnia and Herzegovina", "Botswana", "Brazil", "Brunei", "Bulgaria", "Burkina Faso", "Burundi", "Cabo Verde", "Cambodia",
165
+ "Cameroon", "Canada", "Central African Republic", "Chad", "Chile", "China", "Colombia", "Comoros", "Congo (Congo-Brazzaville)",
166
+ "Costa Rica", "Croatia", "Cuba", "Cyprus", "Czechia (Czech Republic)", "Democratic Republic of the Congo", "Denmark", "Djibouti", "Dominica",
167
+ "Dominican Republic", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Eswatini (fmr. "Swaziland")", "Ethiopia",
168
+ "Fiji", "Finland", "France", "Gabon", "Gambia", "Georgia", "Germany", "Ghana", "Greece", "Grenada",
169
+ "Guatemala", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Honduras", "Hungary", "Iceland", "India", "Indonesia",
170
+ "Iran", "Iraq", "Ireland", "Israel", "Italy", "Jamaica", "Japan", "Jordan", "Kazakhstan", "Kenya",
171
+ "Kiribati", "Korea, North", "Korea, South", "Kuwait", "Kyrgyzstan", "Laos", "Latvia", "Lebanon", "Lesotho", "Liberia",
172
+ "Libya", "Liechtenstein", "Lithuania", "Luxembourg", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta",
173
+ "Marshall Islands", "Mauritania", "Mauritius", "Mexico", "Micronesia", "Moldova", "Monaco", "Mongolia", "Montenegro", "Morocco",
174
+ "Mozambique", "Myanmar (formerly Burma)", "Namibia", "Nauru", "Nepal", "Netherlands", "New Zealand", "Nicaragua", "Niger", "Nigeria",
175
+ "North Macedonia", "Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines",
176
+ "Poland", "Portugal", "Qatar", "Romania", "Russia", "Rwanda", "Saint Kitts and Nevis", "Saint Lucia", "Saint Vincent and the Grenadines", "Samoa",
177
+ "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia", "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia",
178
+ "Solomon Islands", "Somalia", "South Africa", "South Sudan", "Spain", "Sri Lanka", "Sudan", "Suriname", "Sweden", "Switzerland",
179
+ "Syria", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "Timor-Leste", "Togo", "Tonga", "Trinidad and Tobago", "Tunisia",
180
+ "Turkey", "Turkmenistan", "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States of America", "Uruguay",
181
+ "Uzbekistan", "Vanuatu", "Vatican City", "Venezuela", "Vietnam", "Yemen", "Zambia", "Zimbabwe"
182
+ ]
183
 
184
  # Function to update the dropdown choices
185
  def update_dropdown_choices():
186
+ return gr.update(choices=["All"] + ALL_COUNTRIES, value="All")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
187
 
188
  # Setup Gradio interface
189
  with gr.Blocks() as demo:
 
196
  name = gr.Text(label="Name")
197
  discord = gr.Text(label="πŸ‘€ Discord Username *")
198
  city = gr.Text(label="πŸ“ City *")
199
+ country = gr.Dropdown(label="🌍 Country *", choices=ALL_COUNTRIES, value="All") # Dropdown for Country
200
  address = gr.Text(label="Address (optional)")
201
  looking = gr.Radio(["Yes", "No"], label="πŸ” Looking for a team?")
202
  onlinecheck = gr.Radio(["Participate Online", "Join a Local Hackathon"], label="πŸš€ I will...")