<commit_before><html>
<head>
	<link rel="stylesheet" type="text/css" href="style.css">
	<title>RESTful API</title>
	<script src="libs.js"></script>
	<style>
	#output, #input pre { white-space: pre-wrap }
	</style>
	<script>
		function printinput(obj) {
			replaceDom(byId('input'), obj);
		}

		function run() {
			print('');
			var key = byId('accesskey').value,
				command = byId('command').value,
				parameters = byId('parameters').value;
			localStorage['accesskey'] = key;
			if (parameters.length > 0) {
				try {
					parameters = JSON.parse(parameters);
				} catch (e) {
					print('Bad JSON', true);
					return;
				}
			}
			var base = location.protocol + '//' + location.host;
			var params = '';
			if (Object.keys(parameters).length > 0)
				params = '\t-d \'' + JSON.stringify(parameters) + '\' \\\n';
			printinput(['span', {},
				'This command for cURL util:',
				['pre', {},
					'curl -i -X POST  \\\n',
					'\t-H "Authorization: Bearer YourAccessKeyHere=" \\\n',
					params + '\t' + base + '/api/' + command
				]]);
			ajax('POST', '/api/' + command, parameters, key, function (xmlhttp) {
				err = xmlhttp.status < 200 || xmlhttp.status > 299;
				if (xmlhttp.status == 0) {
					print('Response is not received', true);
				} else {
					print('Response is\nHTTP/1.0 ' + xmlhttp.status + ' ' + xmlhttp.statusText + '\n' +
						xmlhttp.getAllResponseHeaders() + '\n' + xmlhttp.responseText, err);
				}
			});
		}

		function init() {
			byId('accesskey').value = localStorage['accesskey'];
		}
	</script>
</head>
<body onload="init()">
<div class="header">
	<a href="./help.html"><div class="devecihive-logo-text"></div></a>
	<div class="key-box">
		<label for="accesskey">AccesKey: </label>
		<input class="input-accesskey input-data" type="password" id="accesskey">
	</div>
</div>
<div class="content">
	<div class="description">This sample allows to send an arbitrary request and observe a response. Enter command name 
		and parameters which should be valid JSON and click 'Run' button. Some commands use base64 encoding. There is a 
		simple converter <a href='./base64.html' target='_blank'>base64.html</a>.
	</div>
	<div class="form-block">
		<label class="pin-label">Command: <input class="input-data" type="text" id="command" value="gpio/read"></label>
		<label class="pin-label">Parameters:
		<textarea class="margin-reset" id="parameters" rows="10"></textarea>
		</label>
		<button class="btn_event btn_event_green" type="button" value="Run" onclick="run();">Run</button>
		<div class="input_desc extra-margin-top" id="input"></div>
		<div id="output" class="extra-margin-top"></div>
	</div>
</div>
</body>
</html><commit_msg>add command suggestion list on tryapi page<commit_after><html>
<head>
	<link rel="stylesheet" type="text/css" href="style.css">
	<title>RESTful API</title>
	<script src="libs.js"></script>
	<style>
	#output, #input pre { white-space: pre-wrap }
	</style>
	<script>
		function printinput(obj) {
			replaceDom(byId('input'), obj);
		}

		function run() {
			print('');
			var key = byId('accesskey').value,
				command = byId('command').value,
				parameters = byId('parameters').value;
			localStorage['accesskey'] = key;
			if (parameters.length > 0) {
				try {
					parameters = JSON.parse(parameters);
				} catch (e) {
					print('Bad JSON', true);
					return;
				}
			}
			var base = location.protocol + '//' + location.host;
			var params = '';
			if (Object.keys(parameters).length > 0)
				params = '\t-d \'' + JSON.stringify(parameters) + '\' \\\n';
			printinput(['span', {},
				'This command for cURL util:',
				['pre', {},
					'curl -i -X POST  \\\n',
					'\t-H "Authorization: Bearer YourAccessKeyHere=" \\\n',
					params + '\t' + base + '/api/' + command
				]]);
			ajax('POST', '/api/' + command, parameters, key, function (xmlhttp) {
				err = xmlhttp.status < 200 || xmlhttp.status > 299;
				if (xmlhttp.status == 0) {
					print('Response is not received', true);
				} else {
					print('Response is\nHTTP/1.0 ' + xmlhttp.status + ' ' + xmlhttp.statusText + '\n' +
						xmlhttp.getAllResponseHeaders() + '\n' + xmlhttp.responseText, err);
				}
			});
		}

		function init() {
			var key = localStorage['accesskey'];
			byId('accesskey').value = key;

			var base = location.protocol + '//' + location.host;
			ajax('POST', '/api/command/list', '', key, function (xmlhttp) {
				if (xmlhttp.status == 200) {
					var cmd_list = JSON.parse(xmlhttp.responseText);
					var options = '';
					for (var i = 0; i < cmd_list.length; i++) {
						options += '<option value="' + cmd_list[i] + '"/>';
					}
					byId('commands').innerHTML = options;
				}
			});
		}
	</script>
</head>
<body onload="init()">
<div class="header">
	<a href="./help.html"><div class="devecihive-logo-text"></div></a>
	<div class="key-box">
		<label for="accesskey">AccesKey: </label>
		<input class="input-accesskey input-data" type="password" id="accesskey">
	</div>
</div>
<div class="content">
	<div class="description">This sample allows to send an arbitrary request and observe a response. Enter command name 
		and parameters which should be valid JSON and click 'Run' button. Some commands use base64 encoding. There is a 
		simple converter <a href='./base64.html' target='_blank'>base64.html</a>.
	</div>
	<div class="form-block">
		<label class="pin-label">Command: <input class="input-data" type="text" id="command" value="gpio/read" list="commands"></label>
		<datalist id="commands"></datalist>
		<label class="pin-label">Parameters:
		<textarea class="margin-reset" id="parameters" rows="10"></textarea>
		</label>
		<button class="btn_event btn_event_green" type="button" value="Run" onclick="run();">Run</button>
		<div class="input_desc extra-margin-top" id="input"></div>
		<div id="output" class="extra-margin-top"></div>
	</div>
</div>
</body>
</html>
{'fraction_non_alphanumeric': 0.19568567026194145, 'fraction_numerical': 0.007190549563430919, 'mean_word_length': 3.629160063391442, 'pattern_counts': {'":': 0, '<': 103, '<?xml version=': 0, '>': 106, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 19}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3926439', 'n_tokens_mistral': 2275, 'n_tokens_neox': 1938, 'n_words': 465}