import gradio as gr import backend import io def create_file(text): cal_text = backend.generate_text(text) if cal_text == "": raise gr.Error("No calendar data could be generated from the input.") else: file_obj = io.BytesIO(cal_text.encode("utf-8")) file_obj.name = "output.ics" return file_obj with gr.Blocks() as demo: gr.Markdown("# Anything2Cal") gr.Markdown("### Turn any text into a calendar file!") gr.Markdown("## FAQ:") gr.Markdown("### How do you use this?\n1. Enter event details in the box below.\n2. Click the \"2Cal!\" button to generate a calendar file.\n3. Download the generated calendar file.\n4. Open the file with your calendar application.") gr.Markdown("### Does it support multiple events?\nYes, it does. Multiple events will be bunched into a single calendar file.") gr.Markdown("#### Created by @tigeryfan") text_input = gr.Textbox(label="Enter Event Details Here", lines=6) output_file = gr.File(label="Generated Calendar File") btn = gr.Button("2Cal!") btn.click(fn=create_file, inputs=text_input, outputs=output_file) demo.launch()