-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.html
49 lines (47 loc) · 1.4 KB
/
test.html
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
<html>
<head>
<script>
function submitForm() {
var url = document.getElementById("url").value;
var image_preview = document.getElementById("img_preview");
image_preview.src = url;
var text = document.getElementById("text").value;
var server = document.getElementById("server").value;
var data = [{
uri: url,
text
}];
var payload = {
data,
// targetExecutor: "",
// parameters: {},
execEndpoint: "/"
}
var url = server + "/post";
fetch(url, {
method: 'POST',
body: JSON.stringify(payload),
headers: {
'Content-Type': 'application/json'
}
}).then(function(response) {
return response.json();
}).then(function(json) {
const uri = json?.data?.[0]?.matches?.[0]?.uri
var img_response = document.getElementById("img_response");
img_response.src = uri
});
}
</script>
</head>
<body style="zoom: 2">
<form autocomplete="off">
<input type="text" id="url" placeholder="Enter image url" value="https://dub.sh/jpg" />
<input type="text" id="text" placeholder="Enter text" />
<input type="text" id="server" placeholder="Enter server ip" value="http://localhost:8088" />
<input type="button" value="Submit" onclick="submitForm()" />
</form>
<img id="img_preview" />
<img id="img_response" />
</body>
</html>