Skip to content

Commit

Permalink
[feat] add v1,v0 routes
Browse files Browse the repository at this point in the history
[feat] add count param
  • Loading branch information
aabdulbasset committed Sep 28, 2024
1 parent 3674729 commit fde0638
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/api/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,29 @@


@router.get("/masq") # maintain for backwards compatibility
@router.get("/api/v0/masq")
def get_masq_v0(
ua: Union[bool, None] = True,
rf: Union[bool, None] = False,
hd: Union[bool, None] = False,
):
logger.info(f"Request: [{ua=} {rf=} {hd=}]")
response = masq(ua, rf, hd)
logger.info(f"Response: [{response}]")

return JSONResponse(content=response)

@router.get("/api/v1/masq")
def get_masq(
ua: Union[bool, None] = True,
rf: Union[bool, None] = False,
hd: Union[bool, None] = False,
count: Union[int, None] = 1,
):
logger.info(f"Request: [{ua=} {rf=} {hd=}]")
response = masq(ua, rf, hd)
if count >= 250: count = 250
if count <= 0: count = 1
response = [masq(ua, rf, hd) for _ in range(count)]
logger.info(f"Response: [{response}]")

return JSONResponse(content=response)

0 comments on commit fde0638

Please sign in to comment.