Adding inputs for secret to load_data and delete_data functions.
Browse files
app.py
CHANGED
@@ -4,12 +4,14 @@ import os
|
|
4 |
# Define the path to the local storage file
|
5 |
local_storage_file = "local_storage.txt"
|
6 |
|
|
|
|
|
7 |
|
8 |
# Function to retrieve data from query parameters in the URL
|
9 |
def get_query_params(request: gr.Request):
|
10 |
if "secret" not in request.query_params:
|
11 |
return
|
12 |
-
if request.query_params["secret"] !=
|
13 |
return
|
14 |
data = ""
|
15 |
if "filename" in request.query_params:
|
@@ -24,10 +26,8 @@ def get_query_params(request: gr.Request):
|
|
24 |
|
25 |
|
26 |
# Function to load data from local storage
|
27 |
-
def load_data():
|
28 |
-
if
|
29 |
-
return
|
30 |
-
if request.query_params["secret"] != "nevergonnagiveyouup":
|
31 |
return
|
32 |
if os.path.exists(local_storage_file):
|
33 |
with open(local_storage_file, "r") as file:
|
@@ -36,10 +36,8 @@ def load_data():
|
|
36 |
else:
|
37 |
return "No data found!"
|
38 |
|
39 |
-
def delete_data():
|
40 |
-
if
|
41 |
-
return
|
42 |
-
if request.query_params["secret"] != "nevergonnagiveyouup":
|
43 |
return
|
44 |
if os.path.exists(local_storage_file):
|
45 |
os.remove(local_storage_file)
|
@@ -58,14 +56,14 @@ iface1 = gr.Interface(
|
|
58 |
|
59 |
iface2 = gr.Interface(
|
60 |
fn=load_data,
|
61 |
-
inputs=
|
62 |
outputs="text",
|
63 |
title="Load Data"
|
64 |
)
|
65 |
|
66 |
iface3 = gr.Interface(
|
67 |
fn=delete_data,
|
68 |
-
inputs=
|
69 |
outputs="text",
|
70 |
title="Delete Data"
|
71 |
)
|
|
|
4 |
# Define the path to the local storage file
|
5 |
local_storage_file = "local_storage.txt"
|
6 |
|
7 |
+
# Specify the secret value
|
8 |
+
secret_value = "nevergonnagiveyouup"
|
9 |
|
10 |
# Function to retrieve data from query parameters in the URL
|
11 |
def get_query_params(request: gr.Request):
|
12 |
if "secret" not in request.query_params:
|
13 |
return
|
14 |
+
if request.query_params["secret"] != secret_value:
|
15 |
return
|
16 |
data = ""
|
17 |
if "filename" in request.query_params:
|
|
|
26 |
|
27 |
|
28 |
# Function to load data from local storage
|
29 |
+
def load_data(secret):
|
30 |
+
if secret != secret_value:
|
|
|
|
|
31 |
return
|
32 |
if os.path.exists(local_storage_file):
|
33 |
with open(local_storage_file, "r") as file:
|
|
|
36 |
else:
|
37 |
return "No data found!"
|
38 |
|
39 |
+
def delete_data(secret):
|
40 |
+
if secret != secret_value:
|
|
|
|
|
41 |
return
|
42 |
if os.path.exists(local_storage_file):
|
43 |
os.remove(local_storage_file)
|
|
|
56 |
|
57 |
iface2 = gr.Interface(
|
58 |
fn=load_data,
|
59 |
+
inputs="text",
|
60 |
outputs="text",
|
61 |
title="Load Data"
|
62 |
)
|
63 |
|
64 |
iface3 = gr.Interface(
|
65 |
fn=delete_data,
|
66 |
+
inputs="text",
|
67 |
outputs="text",
|
68 |
title="Delete Data"
|
69 |
)
|