Spaces:
Paused
Paused
Download app.py from GmailTrust/save: direct link, hf CLI and curl.
- Browser
- Download file 1.49 kB
-
https://huggingface.co/spaces/GmailTrust/save/resolve/main/app.py
- Command line
-
hf download hf://spaces/GmailTrust/save/app.py
-
curl -L -o app.py https://huggingface.co/spaces/GmailTrust/save/resolve/main/app.py
1.49 kB
| import gradio as gr | |
| from dotenv import load_dotenv | |
| import os | |
| # Load biến môi trường | |
| load_dotenv() | |
| API_KEY = os.getenv('API_KEY', 'default_key') # Mặc định nếu không có .env | |
| email_list = [] | |
| def clear_input(): | |
| return "", "" | |
| def search_email(email_input): | |
| if email_input: | |
| email = email_input.split(';')[0] | |
| found = next((item for item in email_list if item['email'] == email), None) | |
| return f"Found: {found}" if found else "Not found" | |
| return "Please enter an email" | |
| def add_items(email_input): | |
| if email_input: | |
| email, password, recovery = email_input.split(';') | |
| new_item = {'email': email, 'password': password, 'recovery': recovery} | |
| email_list.append(new_item) | |
| return f"Added: {new_item}, Total items: {len(email_list)}" | |
| return "Please enter data" | |
| with gr.Blocks() as demo: | |
| with gr.Row(): | |
| email_input = gr.Textbox(label="Enter email (format: email;password;recovery_email)", | |
| placeholder="abc@gmail.com;pass;recovery@gmail.com") | |
| with gr.Row(): | |
| clear_btn = gr.Button("Xóa") | |
| search_btn = gr.Button("Tìm kiếm") | |
| add_btn = gr.Button("Nhập hàng") | |
| output = gr.Textbox(label="Result") | |
| clear_btn.click(fn=clear_input, inputs=None, outputs=[email_input, output]) | |
| search_btn.click(fn=search_email, inputs=email_input, outputs=output) | |
| add_btn.click(fn=add_items, inputs=email_input, outputs=output) | |
| demo.launch() |