-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Working blocklist checking implementation
- Loading branch information
Janson Bunce
committed
Feb 12, 2025
1 parent
c8ab1b4
commit fecf2d4
Showing
5 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
"""Blocklist API.""" | ||
|
||
# Third-Party Libraries | ||
from fastapi import HTTPException | ||
from xfd_mini_dl.models import Blocklist | ||
|
||
|
||
async def handle_check_ip(ip_address: str): | ||
""" | ||
Determine if an IP exists in our blocklist table. | ||
Returns: | ||
{ status: "BLOCKED" or "UNBLOCKED" } | ||
""" | ||
ip_obj = None | ||
try: | ||
ip_obj = Blocklist.objects.get(ip=ip_address) | ||
except Exception as e: | ||
raise HTTPException(status_code=500, details=str(e)) | ||
if ip_obj: | ||
return {"status": "BLOCKED"} | ||
return {"status": "UNBLOCKED"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters