File size: 1,000 Bytes
cfc5dce 91ec962 74dfba9 91ec962 cfc5dce 91ec962 7ace83c 91ec962 6a07a92 74dfba9 25dffb5 74dfba9 91ec962 cfc5dce |
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 |
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>My static Space</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div class="card">
<h1>Welcome to my GPT test environment!</h1>
<p>Enter a prompt in the textbox to get started</p>
<textarea name="prompt" id="prompt" cols="30" rows="10"></textarea><br>
<button id="submit">Submit</button>
<p id="response"></p>
</div>
</body>
<script>
const btn = document.querySelector("#submit")
const textbox = document.querySelector("#prompt")
const res = document.querySelector("#response")
const prompt = textbox.value
btn.addEventListener("click", event => {
fetch(`/gpt?prompt=${prompt}`)
.then(res => {
console.log(res)
res.json()
})
.then(res => {
console.log(res)
res.textContent = res
})
.catch(err => {
console.log(err)
res.textContent = err
})
})
</script>
</html>
|