-
Notifications
You must be signed in to change notification settings - Fork 1
/
check.py
34 lines (29 loc) · 911 Bytes
/
check.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date : 2019-03-28 17:08:26
import json
import configparser
def token_check1(token):
conf = configparser.ConfigParser()
conf.read("conf/config.ini")
token_key = conf.get('token', 'key')
# token_key="123"
if token == token_key:
data = {"code": 1000}
else:
data = {"code": 1001}
return data
# print(token_check('123qwe'))
def check_token1(token):
def wrapper(func): # 指定宇宙无敌参数
def inner_wrapper(*args, **kwargs):
conf = configparser.ConfigParser()
conf.read("conf/config.ini")
token_key = conf.get('token', 'key')
if token == token_key:
return func(*args, **kwargs)
else:
data = json.dumps({"code": 1001})
return data
return inner_wrapper
return wrapper # 返回