Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import json
|
3 |
+
|
4 |
+
def save_to_json(text1, text2, text3, agree):
|
5 |
+
"""Saves the input text from three text areas to a JSON file if the checkbox is checked."""
|
6 |
+
if agree:
|
7 |
+
data = {
|
8 |
+
"text1": text1,
|
9 |
+
"text2": text2,
|
10 |
+
"text3": text3
|
11 |
+
}
|
12 |
+
with open("data.json", "w") as f:
|
13 |
+
json.dump(data, f)
|
14 |
+
return "Data saved to data.json"
|
15 |
+
else:
|
16 |
+
return "Please agree to the terms before submitting."
|
17 |
+
|
18 |
+
iface = gr.Interface(
|
19 |
+
fn=save_to_json,
|
20 |
+
inputs=[
|
21 |
+
gr.TextArea(lines=5, placeholder="Enter text 1 here..."),
|
22 |
+
gr.TextArea(lines=5, placeholder="Enter text 2 here..."),
|
23 |
+
gr.TextArea(lines=5, placeholder="Enter text 3 here..."),
|
24 |
+
gr.Checkbox(label="I agree and have the rights to share these prompts under the CC-BY license.")
|
25 |
+
],
|
26 |
+
outputs="text",
|
27 |
+
title="Save Text to JSON",
|
28 |
+
description="Enter text in the three areas and click submit to save to a JSON file."
|
29 |
+
)
|
30 |
+
|
31 |
+
iface.launch()
|