Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import requests | |
| API_URL = "http://localhost:8000" # Change to internal URL in Docker if needed | |
| def add_task_ui(title): | |
| response = requests.post(f"{API_URL}/tasks/", json={"id": "", "title": title, "completed": False}) | |
| return get_tasks_ui() | |
| def get_tasks_ui(): | |
| response = requests.get(f"{API_URL}/tasks/") | |
| return [f"{task['title']} - {'✔️' if task['completed'] else '❌'}" for task in response.json()] | |
| with gr.Blocks() as demo: | |
| with gr.Row(): | |
| task_input = gr.Textbox(label="New Task") | |
| add_button = gr.Button("Add Task") | |
| task_list = gr.Textbox(label="Tasks", lines=10) | |
| add_button.click(add_task_ui, inputs=task_input, outputs=task_list) | |
| demo.launch() | |