viewer and parser added
All checks were successful
SonarQube Scan / SonarQube Trigger (push) Successful in 1m44s

This commit is contained in:
dongho
2024-12-20 00:00:21 +09:00
parent f8fe2c089f
commit 0db0405ea1
6 changed files with 407 additions and 51 deletions

123
templates/coin.html Normal file
View File

@ -0,0 +1,123 @@
<!DOCTYPE html>
<html>
<head>
<title>XRP Price Live Chart</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.7.0/chart.min.js"></script>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
background-color: #f5f5f5;
}
.container {
max-width: 1200px;
margin: 0 auto;
background-color: white;
padding: 20px;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
h1 {
color: #333;
text-align: center;
margin-bottom: 20px;
}
.chart-container {
position: relative;
height: 60vh;
width: 100%;
}
</style>
</head>
<body>
<div class="container">
<h1>XRP Price Live Chart</h1>
<div class="chart-container">
<canvas id="priceChart"></canvas>
</div>
</div>
<script>
let chart;
async function fetchData() {
try {
const response = await fetch('/data/{{coin}}');
const data = await response.json();
return data;
} catch (error) {
console.error('Error fetching data:', error);
return null;
}
}
async function updateChart() {
const data = await fetchData();
if (!data) return;
if (chart) {
chart.data.labels = data.times;
chart.data.datasets[0].data = data.prices;
chart.update();
} else {
const ctx = document.getElementById('priceChart').getContext('2d');
chart = new Chart(ctx, {
type: 'line',
data: {
labels: data.times,
datasets: [{
label: 'XRP Price (USD)',
data: data.prices,
borderColor: 'rgb(75, 192, 192)',
borderWidth: 2,
fill: true,
backgroundColor: 'rgba(75, 192, 192, 0.1)',
tension: 0.1,
pointRadius: 1,
pointHoverRadius: 5
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: {
position: 'top',
},
title: {
display: true,
text: 'XRP Price History'
}
},
scales: {
y: {
beginAtZero: false,
ticks: {
callback: function(value) {
return '$' + value.toFixed(4);
}
}
},
x: {
ticks: {
maxTicksLimit: 10,
maxRotation: 45,
minRotation: 45
}
}
},
interaction: {
intersect: false,
mode: 'index'
}
}
});
}
}
// Update every 5 seconds
updateChart();
setInterval(updateChart, 5000);
</script>
</body>
</html>

41
templates/index.html Normal file
View File

@ -0,0 +1,41 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Billionaire yes</title>
<style>
/* Add your CSS here */
body {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
}
</style>
</head>
<body>
<!-- Add your content here -->
<header>
<h1>To Become Billionaire</h1>
</header>
<main>
<section>
<h2>Interested Coints Live Chart</h2>
<ul>
{% for coin in coins %}
<li><a href="/coin/{{coin}}">{{coin}}</a></li>
{% endfor %}
</ul>
</section>
</main>
<footer>
<p>&copy; 2024 Dongho Kim</p>
</footer>
<script>
// Add your JavaScript here
</script>
</body>
</html>