-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
123 lines (104 loc) · 2.8 KB
/
index.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
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
115
116
117
118
119
120
121
122
123
<!DOCTYPE html>
<html>
<head>
<title>Content Summarization and Image Generation</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<style>
textarea {
padding: 20px;
width: 700px;
height: 300px;
}
.container {
display: flex;
justify-content: center;
}
input[type=button] {
float: right;
}
.header {
text-align: center;
font-size: 24px;
}
#response {
width: 718px;
margin-top: 40px;
line-height: 23px;
background-color: #fbfbfb;
padding: 13px;
}
.title {
font-size: 18px;
text-align: center;
margin-top: 25px;
}
.story {
text-align: center;
padding: 13px;
}
.picture {
display: flex;
justify-content: center;
margin: 6px;
}
</style>
</head>
<body>
<div class="container">
<div>
<div class="header">Text Summarization and Image Generation</div>
<div class="story"><a href="https://read.gov/aesop/013.html" target="_blank">Animal Stories</a></div>
<div id="wait"></div>
<div>
<textArea id="content" placeholder="Please provide a story about an animal."></textArea>
</div>
<div>
<input id="process" type="button" value="Process">
</div>
<div id="response">
</div>
</div>
</div>
<script>
$(document).ready(function() {
function getData(data) {
$("#wait").text("Wait...")
$.ajax({
type: 'POST',
url: '/api/data',
data,
success: function(response) {
$('#response').append(`
<div>${$("#content").val()}</div>
<div class="title"><b>Summarization</b></div>
<div>${response.summarized}</div>`
);
const imageText = `${response.structuredOutput.Adjective} ${response.structuredOutput['Animal name']}`
$('#response').append(`
<div class="title"><b>Text to Image (${imageText})</b></div>`
);
$('#response').append(`
<div class="picture"><img src="${response.replicateResponse}" alt="${imageText}" title="${imageText}" /></div>`
);
$('#response').append("<hr />")
$("#content").val("")
$("#wait").text("")
},
error: function(xhr, status, error) {
$("#wait").text("")
alert(error)
}
});
}
$("#process").click(function (e) {
const content = $("#content").val()
if(!content) {
alert("Please provide a story about an animal.")
return
}
getData({ content })
});
});
</script>
</body>
</html>