theguywhosucks commited on
Commit
bd28db0
·
verified ·
1 Parent(s): 753aca2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +46 -2
app.py CHANGED
@@ -63,7 +63,7 @@ def upload_file(user_id, password, file, custom_name):
63
  return str(e)
64
 
65
  # -------------------------
66
- # GET DOWNLOAD LINK ONLY
67
  # -------------------------
68
  def download_file(user_id, password, filename):
69
 
@@ -81,8 +81,30 @@ def download_file(user_id, password, filename):
81
  api_name="/get_download_link_action"
82
  )
83
 
84
- return link # just display the link
 
 
85
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  except Exception as e:
87
  return str(e)
88
 
@@ -114,6 +136,9 @@ with gr.Blocks(title="Pockit Cloud Client") as app:
114
  user = gr.Textbox(label="User ID")
115
  pw = gr.Textbox(label="Password", type="password")
116
 
 
 
 
117
  with gr.Tab("Login"):
118
  login_btn = gr.Button("Login")
119
  login_status = gr.Textbox(label="Status")
@@ -125,6 +150,9 @@ with gr.Blocks(title="Pockit Cloud Client") as app:
125
  outputs=[login_status, login_files]
126
  )
127
 
 
 
 
128
  with gr.Tab("Files"):
129
 
130
  refresh_btn = gr.Button("Refresh File List")
@@ -137,6 +165,8 @@ with gr.Blocks(title="Pockit Cloud Client") as app:
137
  outputs=[status_box, file_list]
138
  )
139
 
 
 
140
  download_btn = gr.Button("Get Download Link")
141
  download_output = gr.Textbox(label="Download Link")
142
 
@@ -159,6 +189,20 @@ with gr.Blocks(title="Pockit Cloud Client") as app:
159
  outputs=upload_status
160
  )
161
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
162
  with gr.Tab("Password"):
163
  new_pw = gr.Textbox(label="New Password", type="password")
164
  change_btn = gr.Button("Change Password")
 
63
  return str(e)
64
 
65
  # -------------------------
66
+ # GET DOWNLOAD LINK
67
  # -------------------------
68
  def download_file(user_id, password, filename):
69
 
 
81
  api_name="/get_download_link_action"
82
  )
83
 
84
+ return link
85
+ except Exception as e:
86
+ return str(e)
87
 
88
+ # -------------------------
89
+ # DELETE FILE
90
+ # -------------------------
91
+ def delete_file(user_id, password, filename):
92
+
93
+ if not user_id or not password:
94
+ return "Username and password required"
95
+
96
+ if not filename:
97
+ return "No file selected"
98
+
99
+ try:
100
+ result = client.predict(
101
+ user_id=user_id,
102
+ password=password,
103
+ filename=filename,
104
+ api_name="/delete_file_secure"
105
+ )
106
+
107
+ return result
108
  except Exception as e:
109
  return str(e)
110
 
 
136
  user = gr.Textbox(label="User ID")
137
  pw = gr.Textbox(label="Password", type="password")
138
 
139
+ # -------------------------
140
+ # LOGIN TAB
141
+ # -------------------------
142
  with gr.Tab("Login"):
143
  login_btn = gr.Button("Login")
144
  login_status = gr.Textbox(label="Status")
 
150
  outputs=[login_status, login_files]
151
  )
152
 
153
+ # -------------------------
154
+ # FILES TAB
155
+ # -------------------------
156
  with gr.Tab("Files"):
157
 
158
  refresh_btn = gr.Button("Refresh File List")
 
165
  outputs=[status_box, file_list]
166
  )
167
 
168
+ gr.Markdown("### Get Download Link")
169
+
170
  download_btn = gr.Button("Get Download Link")
171
  download_output = gr.Textbox(label="Download Link")
172
 
 
189
  outputs=upload_status
190
  )
191
 
192
+ gr.Markdown("### Delete File")
193
+
194
+ delete_btn = gr.Button("Delete Selected File")
195
+ delete_status = gr.Textbox(label="Delete Status")
196
+
197
+ delete_btn.click(
198
+ delete_file,
199
+ inputs=[user, pw, file_list],
200
+ outputs=delete_status
201
+ )
202
+
203
+ # -------------------------
204
+ # PASSWORD TAB
205
+ # -------------------------
206
  with gr.Tab("Password"):
207
  new_pw = gr.Textbox(label="New Password", type="password")
208
  change_btn = gr.Button("Change Password")