checkin / app.py
freddyaboulton's picture
private dataset
fb18c58
raw
history blame
1.03 kB
import pandas as pd
import gradio as gr
from huggingface_hub import hf_hub_download
import os
guest_list = hf_hub_download("freddyaboulton/names", "guests.csv", repo_type="dataset",
token=os.environ["TOKEN"])
GUESTS = set(pd.read_csv(guest_list).Name.str.lower())
def checkin(s: str):
s = s.lower()
color = "green" if s in GUESTS else "red"
value = "on list" if s in GUESTS else "not on list"
return gr.Label.update(value=value, color=color)
with gr.Blocks() as demo:
with gr.Row():
with gr.Column():
name = gr.Textbox(label="Name", info="Name on Partiful. Case insensitive. Hit enter or button")
checkin_btn = gr.Button(value="Check in")
# add = gr.Button(value="Add name to list")
with gr.Column():
result = gr.Label(label="Are they on the list?")
name.submit(checkin, name, result)
checkin_btn.click(checkin, name, result)
# add.click(add_to_list, name, None)
demo.launch(enable_queue=False)