File size: 6,101 Bytes
7b449d7 |
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 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Capybara Dating App - Personality Quiz</title>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Poppins', sans-serif;
max-width: 800px;
margin: 0 auto;
padding: 20px;
background-color: #f0e6d2;
color: #5a3921;
line-height: 1.6;
}
.container {
background-color: #fff;
border-radius: 15px;
padding: 30px;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
h1 {
color: #ff6b35;
text-align: center;
font-size: 2.5em;
margin-bottom: 20px;
}
#question, #result {
font-size: 1.2em;
margin-bottom: 20px;
background-color: #fffaf0;
padding: 20px;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
#answer {
width: 100%;
padding: 15px;
margin-bottom: 20px;
border: 2px solid #ff6b35;
border-radius: 8px;
font-size: 1em;
transition: border-color 0.3s ease;
}
#answer:focus {
outline: none;
border-color: #ff4500;
}
button {
padding: 12px 24px;
font-size: 1em;
background-color: #ff6b35;
color: white;
border: none;
border-radius: 25px;
cursor: pointer;
transition: background-color 0.3s ease, transform 0.1s ease;
}
button:hover {
background-color: #ff4500;
transform: translateY(-2px);
}
button:active {
transform: translateY(0);
}
#history {
margin-top: 30px;
}
.history-item {
background-color: #fffaf0;
padding: 15px;
margin-bottom: 15px;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.capybara-img {
max-width: 200px;
display: block;
margin: 0 auto 20px;
border-radius: 50%;
}
.quiz-progress {
text-align: center;
margin-bottom: 20px;
font-weight: 600;
color: #5a3921;
}
</style>
</head>
<body>
<div class="container">
<img src="https://placekitten.com/200/200" alt="Cute Capybara" class="capybara-img">
<h1>Capybara Dating App Personality Quiz</h1>
<div id="quiz">
<div class="quiz-progress">Question <span id="current-question">1</span> of 5</div>
<div id="question"></div>
<textarea id="answer" rows="4" placeholder="Type your answer here... Be as honest as a capybara!"></textarea>
<button id="submit">Next Question</button>
</div>
<div id="result" style="display: none;"></div>
<div id="history"></div>
</div>
<script>
const API_URL = 'http://localhost:5000';
let questions = [];
let answers = [];
let currentQuestion = '';
async function getNextQuestion() {
const response = await fetch(`${API_URL}/generate_question`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ previous_questions: questions, previous_answers: answers }),
});
const data = await response.json();
return data.question;
}
async function classifyPersonality() {
const response = await fetch(`${API_URL}/classify_personality`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ questions, answers }),
});
const data = await response.json();
return data;
}
async function startQuiz() {
currentQuestion = await getNextQuestion();
document.getElementById('question').textContent = currentQuestion;
}
document.getElementById('submit').addEventListener('click', async () => {
const answer = document.getElementById('answer').value.trim();
if (answer) {
questions.push(currentQuestion);
answers.push(answer);
document.getElementById('history').innerHTML += `
<div class="history-item">
<p><strong>Q: ${currentQuestion}</strong></p>
<p>A: ${answer}</p>
</div>
`;
document.getElementById('answer').value = '';
if (questions.length < 5) {
currentQuestion = await getNextQuestion();
document.getElementById('question').textContent = currentQuestion;
document.getElementById('current-question').textContent = questions.length + 1;
} else {
const result = await classifyPersonality();
document.getElementById('quiz').style.display = 'none';
document.getElementById('result').style.display = 'block';
document.getElementById('result').innerHTML = `
<h2>Your Capybara Dating Personality:</h2>
<p>${result.personality}</p>
<p>Your personality summary has been saved to: ${result.summary_file}</p>
<button onclick="location.reload()">Take Quiz Again</button>
`;
}
}
});
startQuiz();
</script>
</body>
</html> |