Skip to content

Commit

Permalink
support base64 encoding request
Browse files Browse the repository at this point in the history
  • Loading branch information
scampion committed Jan 16, 2025
1 parent 6bd2413 commit 44ff225
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions piiranha_server.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import base64

from fastapi import FastAPI, HTTPException
from pydantic import BaseModel
import torch
Expand Down Expand Up @@ -133,6 +135,13 @@ async def check_pii(input_data: TextInput):
raise HTTPException(status_code=400, detail="PII detected in input")
return {"status": "OK", "message": "No PII detected"}

@app.post("/check-pii-base64")
async def check_pii(input_data: TextInput):
"""Endpoint to check for PII in input text"""
text = base64.b64decode(input_data.text).decode('utf-8')
if contains_pii(text):
raise HTTPException(status_code=400, detail="PII detected in input")
return {"status": "OK", "message": "No PII detected"}

@app.post("/mask-pii")
async def mask_pii_endpoint(input_data: TextInput, aggregate_redaction: bool = True):
Expand Down

0 comments on commit 44ff225

Please sign in to comment.