DmitrMakeev
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1038,6 +1038,39 @@ def send_ns(*args):
|
|
1038 |
def users():
|
1039 |
return render_template('user.html')
|
1040 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1041 |
|
1042 |
|
1043 |
|
|
|
1038 |
def users():
|
1039 |
return render_template('user.html')
|
1040 |
|
1041 |
+
@app.route('/get_vk_user_info', methods=['GET'])
|
1042 |
+
def get_vk_user_info():
|
1043 |
+
token = request.args.get('token')
|
1044 |
+
if not token:
|
1045 |
+
return jsonify({'error': 'Token is required'}), 400
|
1046 |
+
|
1047 |
+
url = f'https://api.vk.com/method/users.get?v=5.131&access_token={token}'
|
1048 |
+
response = requests.get(url)
|
1049 |
+
|
1050 |
+
if response.status_code != 200:
|
1051 |
+
return jsonify({'error': 'Failed to get user info'}), response.status_code
|
1052 |
+
|
1053 |
+
data = response.json()
|
1054 |
+
if 'response' in data and len(data['response']) > 0:
|
1055 |
+
user_id = data['response'][0]['id']
|
1056 |
+
return jsonify({'user_id': user_id})
|
1057 |
+
else:
|
1058 |
+
return jsonify({'error': 'Failed to get user info'}), 500
|
1059 |
+
|
1060 |
+
|
1061 |
+
|
1062 |
+
|
1063 |
+
|
1064 |
+
|
1065 |
+
|
1066 |
+
|
1067 |
+
|
1068 |
+
|
1069 |
+
|
1070 |
+
|
1071 |
+
|
1072 |
+
|
1073 |
+
|
1074 |
|
1075 |
|
1076 |
|