File size: 1,153 Bytes
a0af69f
 
 
 
 
 
6ed5432
a0af69f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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()