Spaces:
Paused
Paused
Update main.py
Browse files
main.py
CHANGED
|
@@ -101,6 +101,8 @@ app = FastAPI(
|
|
| 101 |
docs_url="/",
|
| 102 |
)
|
| 103 |
|
|
|
|
|
|
|
| 104 |
timeout = 100
|
| 105 |
contact_support = """
|
| 106 |
We are aware that this service is currently offline. This seems to be caused by the API
|
|
@@ -209,6 +211,26 @@ def get_all_banned():
|
|
| 209 |
return banned_users
|
| 210 |
|
| 211 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 212 |
@app.get("/UFoP/blacklist-words")
|
| 213 |
def blacklist_words():
|
| 214 |
try:
|
|
|
|
| 101 |
docs_url="/",
|
| 102 |
)
|
| 103 |
|
| 104 |
+
trans = SyncTranslator()
|
| 105 |
+
|
| 106 |
timeout = 100
|
| 107 |
contact_support = """
|
| 108 |
We are aware that this service is currently offline. This seems to be caused by the API
|
|
|
|
| 211 |
return banned_users
|
| 212 |
|
| 213 |
|
| 214 |
+
@app.get("/ufop/translate", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
|
| 215 |
+
def get_translate(
|
| 216 |
+
item: TranslateCustom,
|
| 217 |
+
):
|
| 218 |
+
try:
|
| 219 |
+
source = trans.detect(item.text)
|
| 220 |
+
translation = trans(item.text, sourcelang=source, targetlang=item.setlang)
|
| 221 |
+
return SuccessResponse(
|
| 222 |
+
status="True",
|
| 223 |
+
randydev={
|
| 224 |
+
"translation": translation.text,
|
| 225 |
+
"translation_original": item.text
|
| 226 |
+
}
|
| 227 |
+
)
|
| 228 |
+
except:
|
| 229 |
+
return SuccessResponse(
|
| 230 |
+
status="False",
|
| 231 |
+
randydev={"message": contact_support})
|
| 232 |
+
|
| 233 |
+
|
| 234 |
@app.get("/UFoP/blacklist-words")
|
| 235 |
def blacklist_words():
|
| 236 |
try:
|