Spaces:
Sleeping
Sleeping
Commit Β·
07d43b2
1
Parent(s): ec0b40d
expose predict/explain/check_domain JSON endpoints for external clients
Browse files
app.py
CHANGED
|
@@ -236,6 +236,9 @@ body{background:var(--bg)!important}
|
|
| 236 |
.tabs > .tab-nav > button.selected{color:var(--ink)!important;background:var(--panel2)!important}
|
| 237 |
.block-label,.label-wrap span{font-size:.7rem!important;font-weight:700!important;
|
| 238 |
letter-spacing:.05em;text-transform:uppercase;color:var(--faint)!important}
|
|
|
|
|
|
|
|
|
|
| 239 |
"""
|
| 240 |
|
| 241 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -650,6 +653,22 @@ with gr.Blocks(title="ScamShield β Smishing Detector") as demo:
|
|
| 650 |
|
| 651 |
gr.HTML(FOOT)
|
| 652 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 653 |
THEME = gr.themes.Soft(primary_hue="indigo", neutral_hue="slate", font=["Inter", "system-ui", "sans-serif"])
|
| 654 |
|
| 655 |
if __name__ == "__main__":
|
|
|
|
| 236 |
.tabs > .tab-nav > button.selected{color:var(--ink)!important;background:var(--panel2)!important}
|
| 237 |
.block-label,.label-wrap span{font-size:.7rem!important;font-weight:700!important;
|
| 238 |
letter-spacing:.05em;text-transform:uppercase;color:var(--faint)!important}
|
| 239 |
+
|
| 240 |
+
/* hidden plumbing for the JSON API */
|
| 241 |
+
.api-hidden{display:none!important}
|
| 242 |
"""
|
| 243 |
|
| 244 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
| 653 |
|
| 654 |
gr.HTML(FOOT)
|
| 655 |
|
| 656 |
+
# ββ Hidden JSON endpoints ββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 657 |
+
# A function only becomes an API route once it is wired to an event, so the
|
| 658 |
+
# JSON API is exposed through zero-height components rather than by being
|
| 659 |
+
# called directly.
|
| 660 |
+
_api_msg = gr.Textbox(visible=False, elem_classes="api-hidden")
|
| 661 |
+
_api_json = gr.JSON(visible=False)
|
| 662 |
+
_api_dom = gr.Textbox(visible=False)
|
| 663 |
+
_api_dom_json = gr.JSON(visible=False)
|
| 664 |
+
|
| 665 |
+
_api_msg.change(fn=predict_api, inputs=_api_msg, outputs=_api_json,
|
| 666 |
+
api_name="predict", show_progress="hidden")
|
| 667 |
+
_api_msg.change(fn=explain_api, inputs=_api_msg, outputs=_api_json,
|
| 668 |
+
api_name="explain", show_progress="hidden")
|
| 669 |
+
_api_dom.change(fn=check_domain_api, inputs=_api_dom, outputs=_api_dom_json,
|
| 670 |
+
api_name="check_domain", show_progress="hidden")
|
| 671 |
+
|
| 672 |
THEME = gr.themes.Soft(primary_hue="indigo", neutral_hue="slate", font=["Inter", "system-ui", "sans-serif"])
|
| 673 |
|
| 674 |
if __name__ == "__main__":
|