fetch

# ------------------------------------------------------------------------------
def send_response(code, **data):
	"""
	"""
	response = {}  # словник-відповідь в JS
	response['code'] = code
	response['data'] = data

	log.debug(f'Send Response = {response}')
	print(json.dumps(response))
	sys.exit(code)
#def

max_num = _db.query('list', 'SELECT MAX(act) FROM receipt')
if _db.error:
	send_response( 301, **{
		'mess'  : tr('ERR_DB'),
		'debug' : _db.errmsg if int(_conf.get('debug')) else ''
	})
else:
	max_num = max_num[0][0]  # query('list',...) повертає [(N,)]
	log.debug(max_num)
	if max_num is None:
		# коли ще нема записів - NULL
		next_num = 1;
	else:
		next_num = int(max_num) + 1
		# next_num = int(max_num) + 1  # query з 'list' повертає [(N,)]

	log.debug(f'SQL-запит 401 ОК')
	send_response( 0, **{
		'mess' : 'ok',
		'num'  : next_num,
	})

Last updated