up
This commit is contained in:
parent
34f233ab60
commit
69edc5201b
6 changed files with 129 additions and 1 deletions
70
devops/index.html
Normal file
70
devops/index.html
Normal file
|
@ -0,0 +1,70 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Test API Feedback</title>
|
||||
<style>
|
||||
body { font-family: Arial, sans-serif; margin: 2em; }
|
||||
#response { margin-top: 1em; padding: 1em; border: 1px solid #ccc; background: #f9f9f9; }
|
||||
label, input, textarea { display: block; margin-bottom: 0.5em; }
|
||||
button { padding: 0.5em 1em; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Envoyer un feedback à l'API</h1>
|
||||
<form id="feedbackForm">
|
||||
<label for="baseUrl">Base URL de l'API :</label>
|
||||
<input type="url" id="baseUrl" name="baseUrl" required value="http://localhost:8501">
|
||||
|
||||
<label for="conversationID">Conversation ID :</label>
|
||||
<input type="text" id="conversationID" name="conversationID" required value="test-conv">
|
||||
|
||||
<label for="feedback">Votre feedback :</label>
|
||||
<textarea id="feedback" name="feedback" rows="4" required></textarea>
|
||||
|
||||
<button type="submit">Envoyer le feedback</button>
|
||||
</form>
|
||||
<div id="response"></div>
|
||||
|
||||
<script>
|
||||
// Initialiser et persister la base URL dans localStorage
|
||||
(function initBaseUrl() {
|
||||
const baseUrlInput = document.getElementById('baseUrl');
|
||||
const saved = localStorage.getItem('apiBaseUrl') || 'http://localhost:8501';
|
||||
baseUrlInput.value = saved;
|
||||
baseUrlInput.addEventListener('input', function () {
|
||||
localStorage.setItem('apiBaseUrl', baseUrlInput.value);
|
||||
});
|
||||
})();
|
||||
|
||||
document.getElementById('feedbackForm').addEventListener('submit', async function(e) {
|
||||
e.preventDefault();
|
||||
const baseUrl = (document.getElementById('baseUrl').value || 'http://localhost:8501').replace(/\/+$/, '');
|
||||
const conversationID = document.getElementById('conversationID').value;
|
||||
const feedback = document.getElementById('feedback').value;
|
||||
const responseDiv = document.getElementById('response');
|
||||
responseDiv.textContent = "Envoi en cours...";
|
||||
|
||||
try {
|
||||
const res = await fetch(`${baseUrl}/api/v1/${encodeURIComponent(conversationID)}/feedback`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ feedback })
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
const errText = await res.text();
|
||||
responseDiv.textContent = `Erreur: ${res.status} - ${errText}`;
|
||||
} else {
|
||||
const data = await res.json();
|
||||
responseDiv.textContent = "Réponse de l'API :\n" + JSON.stringify(data, null, 2);
|
||||
}
|
||||
} catch (err) {
|
||||
responseDiv.textContent = "Erreur lors de la requête : " + err;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue