Skip to content

Commit

Permalink
update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Qewertyy committed Feb 18, 2024
1 parent fb03f5f commit 53b1d9e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
12 changes: 9 additions & 3 deletions examples/antinsfw.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@

def main(image_url: str) -> dict:
client = Client()
response = client.AntiNsfw(image_url)
if response['content']['sfw'] == True:
response = client.AntiNsfw(image_url,29)
print(response)
if 'sfw' in response['content'] and response['content']['sfw'] == True:
return "This image is safe for work."
elif 'isNsfw' in response['content']:
if response['content']['isNsfw'] == True:
return "This image is not safe for work."
else:
return "This image is safe for work."
else:
return "This image is not safe for work."

if __name__ == "__main__":
print(main("https://graph.org/file/13e95c6cc932530823391.png"))
print(main("https://graph.org/file/de1888dd4fdfbc647c398.jpg"))
12 changes: 9 additions & 3 deletions examples/async_antinsfw.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@

async def main(image_url: str) -> dict:
client = AsyncClient()
response = await client.AntiNsfw(image_url)
response = await client.AntiNsfw(image_url,29)
await client.close()
if response['content']['sfw'] == True:
print(response)
if 'sfw' in response['content'] and response['content']['sfw'] == True:
return "This image is safe for work."
elif 'isNsfw' in response['content']:
if response['content']['isNsfw'] == True:
return "This image is not safe for work."
else:
return "This image is safe for work."
else:
return "This image is not safe for work."

if __name__ == "__main__":
print(asyncio.run(main("https://graph.org/file/13e95c6cc932530823391.png")))
print(asyncio.run(main("https://graph.org/file/a642e642fe01a917fd5b5.jpg")))

0 comments on commit 53b1d9e

Please sign in to comment.