Spaces:
Sleeping
Sleeping
import gradio as gr | |
import json | |
def save_to_json(text1, text2, text3, agree): | |
"""Saves the input text from three text areas to a JSON file if the checkbox is checked.""" | |
if agree: | |
data = { | |
"text1": text1, | |
"text2": text2, | |
"text3": text3 | |
} | |
with open("data.json", "w") as f: | |
json.dump(data, f) | |
return "Data saved to data.json" | |
else: | |
return "Please agree to the terms before submitting." | |
iface = gr.Interface( | |
fn=save_to_json, | |
inputs=[ | |
gr.TextArea(lines=5, placeholder="Enter text 1 here..."), | |
gr.TextArea(lines=5, placeholder="Enter text 2 here..."), | |
gr.TextArea(lines=5, placeholder="Enter text 3 here..."), | |
gr.Checkbox(label="I agree and have the rights to share these prompts under the CC-BY license.") | |
], | |
outputs="text", | |
title="Save Text to JSON", | |
description="Enter text in the three areas and click submit to save to a JSON file." | |
) | |
iface.launch() |