-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatic.py
112 lines (101 loc) · 3.47 KB
/
static.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
from modules.appdb import *
AUTHIGNORE = False
LOGINTIME = 30
LIMITPAGE = 10
def checkTokenUser(token):
parent_id = 0
conn = mysql.connect()
cursor = conn.cursor()
query = "select * from users where token = '{}' and " \
"tokenLastAccess > NOW() - INTERVAL {} MINUTE;".format(token, LOGINTIME)
print(query)
try:
cursor.execute(query)
if cursor.rowcount == 1:
for userValue in cursor.fetchall():
if userValue[1] is None:
parent_id = userValue[0]
else:
parent_id = userValue[1]
break
return parent_id
else:
return parent_id
except Exception as e:
print(str(e))
return parent_id
def insertLog(id, message):
conn = mysql.connect()
cursor = conn.cursor()
query = "INSERT INTO log (adminID, action) VALUES ({}, '{}')".format(id, message)
print(query)
try:
cursor.execute(query)
conn.commit()
except Exception as e:
print(e)
ERR404 = {
'success': '0',
'message': '404'
}
ERR500 = {
'success': '0',
'message': '500'
}
API_DESC = [
{
'api_url': '/v1/',
'command': 'get',
'comments': 'Описание доступных методов (этот документ)'
},
{
'api_url': '/v1/users',
'command': 'get',
'comments': 'Получить список пользователей'
},
{
'api_url': '/v1/users/{user_id}',
'command': 'get',
'comments': 'Получить пользователя user_id'
},
{
'api_url': '/v1/persons',
'command': 'get',
'comments': 'Получить список персон'
},
{
'api_url': '/v1/persons/{persons_id}',
'command': 'get',
'comments': 'Получить ключевые слова для person_id'
},
{
'api_url': '/v1/persons/rank',
'command': 'get',
'comments': 'Получить список персон с их рангами по всем сайтам'
},
{
'api_url': '/v1/persons/rank/{person_id}',
'command': 'get',
'comments': 'Получить список рангов по всем сайтам для person_id'
},
{
'api_url': '/v1/sites',
'command': 'get',
'comments': 'Получить список сайтов'
},
{
'api_url': '/v1/sites/{site_id}',
'command': 'get',
'comments': 'Получить сайт по site_id'
},
{
'api_url': '/v1/persons/rank/date?_from=YYYYMMDDDHHMMSS&_till=YYYYMMDDDHHMMSS',
'command': 'get',
'comments': 'Получить список персон с их рангами по всем сайтам за период _from _till'
},
{
'api_url': '/v1/persons/rank/{person_id}/date?_from=YYYYMMDDDHHMMSS&_till=YYYYMMDDDHHMMSS',
'command': 'get',
'comments': 'Получить ранг {person_id} по всем сайтам за период _from _till'
},
]