Spaces:
Runtime error
Runtime error
Commit
·
d55732b
1
Parent(s):
77a0383
Update app.py
Browse files
app.py
CHANGED
@@ -139,10 +139,30 @@ def submit(
|
|
139 |
else:
|
140 |
return f"something went wrong {response.status_code} = {response.text}"
|
141 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
with gr.Blocks() as demo2:
|
143 |
gr.Markdown(
|
144 |
"""
|
145 |
-
## Deploy Your Model on 🤗 Endpoint
|
146 |
""")
|
147 |
|
148 |
gr.Markdown("""
|
@@ -302,7 +322,34 @@ with gr.Blocks() as demo2:
|
|
302 |
security_selector],
|
303 |
outputs=status_txt)
|
304 |
|
305 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
306 |
#### Pricing Table(CPU) - 2023/2/22
|
307 |
""")
|
308 |
|
|
|
139 |
else:
|
140 |
return f"something went wrong {response.status_code} = {response.text}"
|
141 |
|
142 |
+
def delete_endpoint(
|
143 |
+
hf_token_input,
|
144 |
+
endpoint_name_input
|
145 |
+
):
|
146 |
+
response = requests.delete(
|
147 |
+
f"https://api.endpoints.huggingface.cloud/endpoint/{endpoint_name_input}",
|
148 |
+
headers = {
|
149 |
+
"Authorization": f"Bearer {hf_token_input.strip()}",
|
150 |
+
"Content-Type": "application/json",
|
151 |
+
}
|
152 |
+
)
|
153 |
+
if response.status_code == 401:
|
154 |
+
return "Invalid token"
|
155 |
+
elif response.status_code == 404:
|
156 |
+
return f"Error: {response.text}"
|
157 |
+
elif response.status_code == 202:
|
158 |
+
return f"Endpoint {endpoint_name_input} deleted successfully."
|
159 |
+
else:
|
160 |
+
return f"something went wrong {response.status_code} = {response.text}"
|
161 |
+
|
162 |
with gr.Blocks() as demo2:
|
163 |
gr.Markdown(
|
164 |
"""
|
165 |
+
## <center>(Deploy Your Model on 🤗 Endpoint)</center>
|
166 |
""")
|
167 |
|
168 |
gr.Markdown("""
|
|
|
322 |
security_selector],
|
323 |
outputs=status_txt)
|
324 |
|
325 |
+
# Delete Endpoint
|
326 |
+
gr.Markdown("""
|
327 |
+
### <center>(Delete Endpoint)</center><
|
328 |
+
""")
|
329 |
+
delete_endpoint_name_input = gr.Textbox(
|
330 |
+
show_label=False
|
331 |
+
)
|
332 |
+
|
333 |
+
delete_button = gr.Button(
|
334 |
+
value="Delete",
|
335 |
+
)
|
336 |
+
|
337 |
+
delete_status_txt = gr.Textbox(
|
338 |
+
value="status",
|
339 |
+
interactive=False
|
340 |
+
)
|
341 |
+
|
342 |
+
delete_button.click(
|
343 |
+
delete_endpoint,
|
344 |
+
inputs=[
|
345 |
+
hf_token_input,
|
346 |
+
delete_endpoint_name_input
|
347 |
+
],
|
348 |
+
outputs=delete_status_txt
|
349 |
+
)
|
350 |
+
|
351 |
+
gr.Markdown("""
|
352 |
+
### <center>(Instance Pricing Table)</center>
|
353 |
#### Pricing Table(CPU) - 2023/2/22
|
354 |
""")
|
355 |
|