22 lines
515 B
Python
22 lines
515 B
Python
import functools
|
|
|
|
from flask import request
|
|
|
|
|
|
def api_secret(func):
|
|
"""
|
|
校验接口请求密钥
|
|
"""
|
|
secret = "EZgo9ykxrYuBMYnYmmKIh" # 接口密钥
|
|
|
|
@functools.wraps(func)
|
|
def internal(*args, **kwargs):
|
|
try:
|
|
token = request.headers.get('secret')
|
|
if token != secret:
|
|
return {"info": "接口密钥错误"}, 401
|
|
except Exception:
|
|
return {"info": "请求异常"}, 401
|
|
return func(*args, **kwargs)
|
|
return internal
|