From fde063890db540be9fd7e5fc47d703d6d276201e Mon Sep 17 00:00:00 2001 From: aabdulbasset Date: Sat, 28 Sep 2024 08:53:34 +0300 Subject: [PATCH] [feat] add v1,v0 routes [feat] add count param --- src/api/routes.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/api/routes.py b/src/api/routes.py index 704fe90..b315c11 100644 --- a/src/api/routes.py +++ b/src/api/routes.py @@ -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)