inf04-web2/static/index.html

70 lines
2.4 KiB
HTML
Raw Normal View History

2024-06-20 19:10:59 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Feature Viewer</title>
<script src="/static/vue.global.js"></script>
</head>
<body>
<div id="app">
<h1>Feature Viewer</h1>
<button @click="fetchSequences">Fetch Sequences</button>
<button @click="fetchFeatures">Fetch Features</button>
<div v-if="sequences.length">
<h2>Sequences:</h2>
<ul>
<li v-for="sequence in sequences" :key="sequence.id">
<p><strong>Name:</strong> {{ sequence.name }}</p>
<p><strong>Description:</strong> {{ sequence.description }}</p>
<p><strong>Sequence:</strong> {{ sequence.sequence }}</p>
</li>
</ul>
</div>
<div v-if="features.length">
<h2>Features:</h2>
<ul>
<li v-for="feature in features" :key="feature.id">
<p><strong>Type:</strong> {{ feature.type }}</p>
<p><strong>Location:</strong> {{ feature.location }}</p>
<p><strong>Sequence:</strong> {{ feature.sequence }}</p>
<p><strong>Qualifiers:</strong> {{ feature.qualifiers }}</p>
</li>
</ul>
</div>
</div>
<script>
const { createApp } = Vue;
createApp({
data() {
return {
sequences: [],
features: []
}
},
methods: {
async fetchSequences() {
try {
const response = await fetch('/sequences/');
this.sequences = await response.json();
} catch (error) {
console.error("There was an error fetching the sequences:", error);
}
},
async fetchFeatures() {
try {
const response = await fetch('/features/');
this.features = await response.json();
} catch (error) {
console.error("There was an error fetching the features:", error);
}
}
}
}).mount('#app');
</script>
</body>
</html>