habulaj commited on
Commit
978871d
·
1 Parent(s): 952355b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -2
app.py CHANGED
@@ -1,7 +1,19 @@
1
- from fastapi import FastAPI
 
2
 
3
  app = FastAPI()
4
 
5
  @app.get("/")
6
  def greet_json():
7
- return {"Hello": "World!"}
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI, Query
2
+ from profanity_check import predict
3
 
4
  app = FastAPI()
5
 
6
  @app.get("/")
7
  def greet_json():
8
+ return {"Hello": "World!"}
9
+
10
+ @app.get("/check-profanity/")
11
+ def check_profanity(text: str = Query(..., description="Texto a ser verificado")):
12
+ """
13
+ Verifica se o texto contém palavrões.
14
+ """
15
+ contains_profanity = bool(predict([text])[0]) # 1 significa que contém palavrão
16
+ return {
17
+ "text": text,
18
+ "contains_profanity": contains_profanity
19
+ }