Pamudu13 commited on
Commit
c01c8de
·
verified ·
1 Parent(s): 42a8973

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -0
app.py CHANGED
@@ -53,6 +53,16 @@ def predict_email(email):
53
  prediction = obj.predict(data)[0]
54
  st.write(f"Prediction: {prediction}")
55
 
 
 
 
 
 
 
 
 
 
 
56
 
57
  if st.button("Predict Email"):
58
  if email_input:
 
53
  prediction = obj.predict(data)[0]
54
  st.write(f"Prediction: {prediction}")
55
 
56
+ @app.get("/predict/")
57
+ def predict_spam(email: str):
58
+ """
59
+ This endpoint predicts whether the email is Spam or Ham.
60
+ Query parameter: email (str) - The email text to be classified.
61
+ """
62
+ data = bow.transform([email]).toarray()
63
+ prediction = obj.predict(data)[0]
64
+ return JSONResponse(content={"prediction": prediction})
65
+
66
 
67
  if st.button("Predict Email"):
68
  if email_input: