Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import backend
|
| 3 |
+
import io
|
| 4 |
+
|
| 5 |
+
def create_file(text):
|
| 6 |
+
cal_text = backend.generate_text(text)
|
| 7 |
+
if cal_text is "":
|
| 8 |
+
raise gr.Error("No calendar data could be generated from the input.")
|
| 9 |
+
else:
|
| 10 |
+
file_obj = io.BytesIO(cal_text.encode("utf-8"))
|
| 11 |
+
file_obj.name = "output.ics"
|
| 12 |
+
return file_obj
|
| 13 |
+
|
| 14 |
+
with gr.Blocks() as demo:
|
| 15 |
+
gr.Markdown("# Anything2Cal")
|
| 16 |
+
gr.Markdown("### Turn any text into a calendar file!")
|
| 17 |
+
gr.Markdown("## FAQ:")
|
| 18 |
+
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.")
|
| 19 |
+
gr.Markdown("### Does it support multiple events?\nYes, it does. Multiple events will be bunched into a single calendar file.")
|
| 20 |
+
gr.Markdown("#### Created by @tigeryfan")
|
| 21 |
+
|
| 22 |
+
text_input = gr.Textbox(label="Enter Event Details Here", lines=6)
|
| 23 |
+
output_file = gr.File(label="Generated Calendar File")
|
| 24 |
+
btn = gr.Button("2Cal!")
|
| 25 |
+
|
| 26 |
+
btn.click(fn=create_file, inputs=text_input, outputs=output_file)
|
| 27 |
+
|
| 28 |
+
demo.launch()
|