Skip to content

Commit

Permalink
chore: Update HTTP server URL to use port 18099
Browse files Browse the repository at this point in the history
  • Loading branch information
royshil committed Jun 30, 2024
1 parent b059c44 commit 134b7f2
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions http_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,35 @@ def lifespan(app: FastAPI):
<body>
<script>
function updateScoreboard() {
fetch('http://localhost:8099/json')
fetch('http://localhost:18099/json')
.then(response => response.json())
.then(data => {
const homeScore = data.find(item => item.name === 'Home Score').text;
const awayScore = data.find(item => item.name === 'Away Score').text;
const homeFouls = data.find(item => item.name === 'Home Fouls').text;
const awayFouls = data.find(item => item.name === 'Away Fouls').text;
document.querySelector('.team.home .score').textContent = homeScore;
document.querySelector('.team.away .score').textContent = awayScore;
document.querySelector('.team.home .fouls').textContent = `Fouls: ${homeFouls}`;
document.querySelector('.team.away .fouls').textContent = `Fouls: ${awayFouls}`;
const timeItem = data.find(item => item.name === 'Time');
if (timeItem.state === 'Success') {
if (data.find(item => item.name === 'Home Score') !== undefined) {
const homeScore = data.find(item => item.name === 'Home Score').text;
document.querySelector('.team.home .score').textContent = homeScore;
}
if (data.find(item => item.name === 'Away Score') !== undefined) {
const awayScore = data.find(item => item.name === 'Away Score').text;
document.querySelector('.team.away .score').textContent = awayScore;
}
if (data.find(item => item.name === 'Home Fouls') !== undefined) {
const homeFouls = data.find(item => item.name === 'Home Fouls').text;
document.querySelector('.team.home .fouls').textContent = `Fouls: ${homeFouls}`;
}
if (data.find(item => item.name === 'Away Fouls') !== undefined) {
const awayFouls = data.find(item => item.name === 'Away Fouls').text;
document.querySelector('.team.away .fouls').textContent = `Fouls: ${awayFouls}`;
}
if (data.find(item => item.name === 'Time') !== undefined) {
const timeItem = data.find(item => item.name === 'Time');
if (timeItem.state === 'Success' || timeItem.state === 'SameNoChange') {
const time = timeItem.text;
document.querySelector('.timer').textContent = time;
}
}
})
.catch(error => console.error('Error:', error));
Expand Down

0 comments on commit 134b7f2

Please sign in to comment.