Update app.py
Browse files
app.py
CHANGED
@@ -11,6 +11,8 @@ DATA_FILE = os.path.join(DATA_DIR, "teamup_data.json")
|
|
11 |
BACKUP_DIR = os.path.join(DATA_DIR, "backup")
|
12 |
os.makedirs(DATA_DIR, exist_ok=True)
|
13 |
|
|
|
|
|
14 |
# Init data file
|
15 |
if not os.path.exists(DATA_FILE) or os.path.getsize(DATA_FILE) == 0:
|
16 |
with open(DATA_FILE, "w") as f:
|
@@ -209,5 +211,20 @@ with gr.Blocks(css=".gr-dropdown { max-height: 100px; overflow-y: auto; font-siz
|
|
209 |
for dropdown in [country_filter, city_filter, language_filter]:
|
210 |
dropdown.change(fn=filter_by_fields, inputs=[country_filter, city_filter, language_filter], outputs=[table_html])
|
211 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
212 |
demo.launch()
|
213 |
|
|
|
11 |
BACKUP_DIR = os.path.join(DATA_DIR, "backup")
|
12 |
os.makedirs(DATA_DIR, exist_ok=True)
|
13 |
|
14 |
+
ADMIN_CODE = os.getenv("ADMIN_CODE", "")
|
15 |
+
|
16 |
# Init data file
|
17 |
if not os.path.exists(DATA_FILE) or os.path.getsize(DATA_FILE) == 0:
|
18 |
with open(DATA_FILE, "w") as f:
|
|
|
211 |
for dropdown in [country_filter, city_filter, language_filter]:
|
212 |
dropdown.change(fn=filter_by_fields, inputs=[country_filter, city_filter, language_filter], outputs=[table_html])
|
213 |
|
214 |
+
|
215 |
+
gr.Markdown("---\n### 🛡️ Admin Panel (delete by Discord)")
|
216 |
+
admin_discord = gr.Text(label="Discord Username")
|
217 |
+
admin_code = gr.Text(label="Admin Code", type="password")
|
218 |
+
del_btn = gr.Button("Delete Profile")
|
219 |
+
del_status = gr.Textbox(label="Status", interactive=False)
|
220 |
+
del_btn.click(delete_by_discord, inputs=[admin_discord, admin_code], outputs=del_status)
|
221 |
+
|
222 |
+
# 🔐 CSV Download Section (admin-only)
|
223 |
+
gr.Markdown("---\n### 📥 Admin Export CSV")
|
224 |
+
export_code = gr.Text(label="Admin Code", type="password")
|
225 |
+
download_btn = gr.Button("Generate and Download CSV")
|
226 |
+
download_file = gr.File(label="CSV Export", interactive=False)
|
227 |
+
download_btn.click(fn=download_csv, inputs=[export_code], outputs=[download_file])
|
228 |
+
|
229 |
demo.launch()
|
230 |
|