mirror of
https://github.com/senju1337/senju.git
synced 2025-12-24 07:39:29 +00:00
feat: Add redirection to Haiku page and save in DB
Refs: OPS-22
This commit is contained in:
parent
7e5d61663a
commit
6c698d1528
2 changed files with 7 additions and 4 deletions
|
|
@ -55,5 +55,6 @@ def generate_haiku():
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
json_data = request.get_json()
|
json_data = request.get_json()
|
||||||
prompt = json_data["prompt"]
|
prompt = json_data["prompt"]
|
||||||
haiku = request_haiku(prompt)
|
haiku = request_haiku(prompt)
|
||||||
return haiku.get_json()
|
id = store.save_haiku(haiku)
|
||||||
|
return str(id)
|
||||||
|
|
|
||||||
|
|
@ -57,10 +57,12 @@ document.getElementById("submit-btn").addEventListener("click", function() {
|
||||||
},
|
},
|
||||||
body: JSON.stringify({'prompt': userInput})
|
body: JSON.stringify({'prompt': userInput})
|
||||||
})
|
})
|
||||||
.then(response => response.json())
|
.then(response => response.text())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
responseText.innerHTML = data[0] + "<br>" + data[1] + "<br>" + data[2];
|
//responseText.innerHTML = data[0] + "<br>" + data[1] + "<br>" + data[2];
|
||||||
|
let id = parseInt(data, 10);
|
||||||
|
window.location.replace("/haiku/"+id);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
document.getElementById('result').innerHTML = '<strong>Error:</strong> ' + error.message;
|
document.getElementById('result').innerHTML = '<strong>Error:</strong> ' + error.message;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue