1500Get!
感谢支持!
30get纪念一下
正在写后端api,有没有什么好方法限速?fastapi的那个我不知道为啥就是弄不好。。
附带一个大神解法:
def check_ip(ip):
with open("get_count.csv") as file:
lines = file.readlines()[-50:] # 从后往前搜索最近的50行
for line in reversed(lines):
data = line.strip().split(',')
if data[0] == ip:
timestamp = datetime.strptime(data[1], '%Y-%m-%d %H:%M:%S')
current_time = datetime.now()
time_difference = (current_time - timestamp).total_seconds()
if time_difference < 10:
return False
else:
return True
return True
珍爱api远离不关闭数据库连接
宝塔建的那B数据库怎么都连不上🤬
无语了奥