-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathlocal_postman_server.html
More file actions
115 lines (113 loc) · 4.82 KB
/
local_postman_server.html
File metadata and controls
115 lines (113 loc) · 4.82 KB
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
113
114
<!DOCTYPE html>
<html lang="zh-Hans" ng-app="iotApp">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="a Bucket of Internet Of Things">
<meta name="author" content="cloudzhou">
<title>IotBucket</title>
<!--link href="http://lib.sinaapp.com/js/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet">
<script src="http://lib.sinaapp.com/js/jquery/2.0.3/jquery-2.0.3.min.js"></script>
<script src="http://lib.sinaapp.com/js/bootstrap/3.0.0/js/bootstrap.min.js"></script-->
<link href="http://iot.espressif.cn/static/css/bootstrap.min.css" rel="stylesheet">
<script src="http://iot.espressif.cn/static/js/jquery.min.js"></script>
<script src="http://iot.espressif.cn/static/js/bootstrap.min.js"></script>
<style>
code, .ff { font-size: 20px; font-weight: 500; }
.noradius { border-radius: 0px; }
.margin-top8 { margin-top: 8px; }
.page-header { margin-top: 20px; margin-bottom: 10px; }
pre.terminal {
background-color: #444;
color: #fff;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
-moz-background-clip: padding;
-webkit-background-clip: padding-box;
background-clip: padding-box;
border: none;
position: relative;
margin-top: 10px;
padding: 10px;
text-shadow: none;
background-image: none;
filter: none;
}
</style>
</head>
<body>
<div id="main-wrapper">
<div id="main" class="container">
<div class="row" style="margin-top: 20px">
<div>
<label for="token"><span class="ff">Token:</span></label>
<input id="token" type="text" class="form-control input noradius" placeholder="96c73f149ea9829065029e0df1918ed8761cd47e">
</div>
<h2 class="page-header">1. using <code>/v1/datastreams/<stream name>/datapoint/</code></h2>
<div>
<label for="datapoint"><span class="ff">Datapoint:</span></label>
<form class="form-inline">
<div class="form-group">
<input id="stream" type="text" class="form-control input-sm noradius" placeholder="stream name">
<input id="x" type="text" class="form-control input-sm noradius" placeholder="x">
<input id="y" type="text" class="form-control input-sm noradius" placeholder="y">
<input id="z" type="text" class="form-control input-sm noradius" placeholder="z">
<input id="k" type="text" class="form-control input-sm noradius" placeholder="k">
<input id="l" type="text" class="form-control input-sm noradius" placeholder="l">
</div>
</form>
<button id="call-datapoint" type="submit" class="form-control btn btn-primary noradius margin-top8">Request</button>
</div>
<h2 class="page-header">2. using <code>/v1/device/rpc/</code></h2>
<div>
<label for="rpc"><span class="ff">RPC:</span></label>
<input id="rpc" type="email" class="form-control input noradius" placeholder="action=sys_upgrade&version=v1.8">
<button id="call-rpc" type="submit" class="form-control btn btn-primary noradius margin-top8">Request</button>
</div>
<h2 class="page-header">Response</h2>
<div>
<pre id="response" class="terminal">...</pre>
</div>
</div>
</div>
</div>
<script>
function request(method, url, data){
$('#response').text('......');
var token = $('#token').val();
var p = {
url: url,
type: method,
headers: { "Authorization": "token " + token, },
dataType: 'json',
success: function (data) {
$('#response').text(JSON.stringify(data));
}
}
if(data !== null) {
p['data'] = JSON.stringify(data);
}
$.ajax(p);
}
$('#call-datapoint').click(function(){
var url = '/v1/datastreams/' + $('#stream').val() + '/datapoint/?deliver_to_device=true';
var x = $('#x').val(), y = $('#y').val(), z = $('#z').val(), k = $('#k').val(), l = $('#l').val();
var datapoint = {};
if(x !== null && x != '') { datapoint.x = parseFloat(x); }
if(y !== null && y != '') { datapoint.y = parseFloat(y); }
if(z !== null && z != '') { datapoint.z = parseFloat(z); }
if(k !== null && k != '') { datapoint.k = parseFloat(k); }
if(l !== null && l != '') { datapoint.l = parseFloat(l); }
var data = {"datapoint": datapoint};
request('post', url, data);
});
$('#call-rpc').click(function(){
var url = '/v1/device/rpc/?deliver_to_device=true&' + $('#rpc').val();
var data = null;
request('get', url, data);
});
</script>
</body>
</html>