File tree Expand file tree Collapse file tree 2 files changed +41
-1
lines changed Expand file tree Collapse file tree 2 files changed +41
-1
lines changed Original file line number Diff line number Diff line change @@ -202,4 +202,44 @@ This project is licensed under the [MIT License](LICENSE).
202
202
203
203
The project contains 3 pre-trained models that can be used directly if you want to skip the training step.
204
204
If you don't want to use the package, you can use the API that I have deployed
205
- [ here] ( https://spam-detection-api.adamspierredavid.com/ ) .
205
+ [ here] ( https://spam-detection-api.adamspierredavid.com/ ) .
206
+
207
+ The API is built with Django and the following is an example of how I use it in a personal project:
208
+
209
+ ![ Screenshot] ( ./screenshots/spam-detection-api-example.png )
210
+
211
+ The code:
212
+
213
+ ``` python
214
+ import requests
215
+
216
+
217
+ def check_website_contact_form (request ):
218
+ message_ = request.POST .get(' message' )
219
+ subject = request.POST .get(' subject' )
220
+ # etc...
221
+
222
+ # Concatenate subject and message
223
+ message_with_subject = f ' subject: { subject} . { message_} '
224
+
225
+ # Call the spam detection API
226
+ response = requests.post(
227
+ " https://spam-detection-api.adamspierredavid.com/v1/check-spam/" ,
228
+ json = {' message' : message_with_subject} # Use json parameter instead of data
229
+ )
230
+
231
+ is_spam = False
232
+
233
+ # Check if the API request was successful
234
+ if response.status_code == 200 :
235
+ # Parse the JSON response
236
+ json_response = response.json()
237
+ is_spam = json_response.get(' is_spam' )
238
+
239
+ if is_spam:
240
+ # Do something
241
+ pass
242
+ else :
243
+ # Do something else
244
+ pass
245
+ ```
You can’t perform that action at this time.
0 commit comments