Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline, AutoTokenizer, AutoModelForTokenClassification
|
| 3 |
from key_store import (
|
|
@@ -44,9 +45,8 @@ def create_key(label):
|
|
| 44 |
def get_key_table():
|
| 45 |
rows = list_keys()
|
| 46 |
if not rows:
|
| 47 |
-
return
|
| 48 |
-
|
| 49 |
-
return gr.DataFrame(value=data, headers=["Label", "Key preview", "Status", "Usage", "Created"])
|
| 50 |
|
| 51 |
def do_revoke(full_key):
|
| 52 |
revoke_key(full_key.strip())
|
|
@@ -81,8 +81,11 @@ with gr.Blocks(title="PII Detection API") as demo:
|
|
| 81 |
create_msg = gr.Textbox(label="New key (copy now!)", interactive=False, lines=2)
|
| 82 |
|
| 83 |
gr.Markdown("### All keys")
|
| 84 |
-
|
| 85 |
-
|
|
|
|
|
|
|
|
|
|
| 86 |
|
| 87 |
gr.Markdown("### Revoke or delete a key")
|
| 88 |
with gr.Row():
|
|
|
|
| 1 |
+
import os
|
| 2 |
import gradio as gr
|
| 3 |
from transformers import pipeline, AutoTokenizer, AutoModelForTokenClassification
|
| 4 |
from key_store import (
|
|
|
|
| 45 |
def get_key_table():
|
| 46 |
rows = list_keys()
|
| 47 |
if not rows:
|
| 48 |
+
return []
|
| 49 |
+
return [[r["label"], r["key_preview"], r["status"], r["usage"], r["created_at"]] for r in rows]
|
|
|
|
| 50 |
|
| 51 |
def do_revoke(full_key):
|
| 52 |
revoke_key(full_key.strip())
|
|
|
|
| 81 |
create_msg = gr.Textbox(label="New key (copy now!)", interactive=False, lines=2)
|
| 82 |
|
| 83 |
gr.Markdown("### All keys")
|
| 84 |
+
key_df = gr.DataFrame(
|
| 85 |
+
value=get_key_table(),
|
| 86 |
+
headers=["Label", "Key preview", "Status", "Usage", "Created"],
|
| 87 |
+
interactive=False
|
| 88 |
+
)
|
| 89 |
|
| 90 |
gr.Markdown("### Revoke or delete a key")
|
| 91 |
with gr.Row():
|