Browse Source

Rate limit custom method

master
venkataakhil 2 years ago
parent
commit
bb0654201a
  1. 14
      smart_service/apis/master_api.py

14
smart_service/apis/master_api.py

@ -1,7 +1,7 @@
# Copyright (c) 2021, Hard n Soft Technologies Pvt Ltd and contributors
# For license information, please see license.txt
from frappe.rate_limiter import rate_limit
# from frappe.rate_limiter import rate_limit
import frappe
from frappe.model.document import Document
@ -12,11 +12,11 @@ from smart_service.apis.app_user_login import input_validation
current_db_name = frappe.conf.get("db_name")
@frappe.whitelist(allow_guest=1)
@frappe.whitelist(allow_guest=True)
def masters1():
val = rate_limit(limit=5, seconds=10)
if val != 1:
return val
rate_res = rate_limit(limit=5, seconds=10)
if rate_res != 1:
return rate_res
return 1
@ -40,6 +40,10 @@ def rate_limit(limit, seconds):
@frappe.whitelist()
def masters(args=None, LSD=None):
rate = rate_limit(limit=5, seconds=5)
if rate != 1:
return rate
val = input_validation(args=args)
if val != '':
return {"status": 0, "error": "Parameter's missing:"+val}

Loading…
Cancel
Save