hometify/pages/parse.vue

51 lines
1.3 KiB
Vue

<template>
<div class="flex items-center justify-center min-h-screen bg-gray-100">
<div class="bg-white p-6 rounded-lg shadow-lg text-center max-w-md w-full">
<h1 class="text-2xl font-bold mb-4">Initiate Parse</h1>
<button
@click="parse"
class="bg-blue-500 text-white font-semibold py-2 px-4 rounded hover:bg-blue-700 transition-colors duration-300"
>
Start Parse
</button>
<p v-if="message" class="mt-4 text-green-600">{{ message }}</p>
</div>
</div>
</template>
<script setup>
import { ref } from "vue";
const message = ref("");
const parse = async () => {
message.value = "Starting parse...\n";
const resp = await initiateParse();
};
const initiateParse = async () => {
try {
const response = await fetch("/api/parse", {
method: "POST",
body: JSON.stringify({ id: "searchtext", title: "Test" }),
headers: {
"Content-Type": "application/json",
},
});
const result = await response.json();
if (result.success) {
message.value = 'Parse initiated successfully: ' + JSON.stringify(result);
} else {
message.value = `Error: ${result.message}`;
}
} catch (error) {
message.value = `Error: ${error.message}`;
}
};
</script>
<style>
/* Tailwind CSS se encargará de los estilos, por lo que no se necesita nada aquí */
</style>