#LIBS
from flask import Flask, jsonify, request
#Server_config
server_port = 2222
#ENV_config
# create the Flask app
app = Flask(__name__)
@app.route('/nn_api/v1', methods=['POST'])
def json_example():
global request_data
request_data = request.get_json()
print(request_data) #ДАННУЮ ИНФОРМАЦИЮ ТРЕБУЕТСЯ СОХРАНИТЬ В ПЕРЕМЕННУЮ И ПЕРЕДАТЬ ДАЛЬШЕ
return request_data
if __name__ == '__main__':
# run app in debug mode on port
app.run(debug=True, port=server_port)
#ДАЛЕЕ ТРЕБУЕТСЯ 1 РАЗ ВЫПОЛНИТЬ КОД НА ОСНОВЕ ПОЛУЧЕННЫХ ДАННЫХ
import requests
import pycurl
import json
import io
import pathlib
import os
#re-save fields
task_st1 = json_dict['task']['fields']
json_string = json.dumps(task_st1, indent=4, ensure_ascii=False)
with open('task_fields.json', 'w', encoding='utf-8') as outfile:
json.dump(task_st1, outfile, indent=4, ensure_ascii=False)
#open fields
with open('task_fields.json', encoding="utf8") as file:
json_dict = json.load(file)
#find resp of task (id10)
def task_resp_field(data, target_id):
for item in data:
if item.get('id') == target_id:
return item
return None
task_resp = task_resp_field(json_dict, 10)
# И ТД....