Skip to content

Commit

Permalink
add PodName functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Davide Rossi committed Nov 14, 2024
1 parent aeaaef7 commit 9096314
Show file tree
Hide file tree
Showing 28 changed files with 418 additions and 36 deletions.
12 changes: 10 additions & 2 deletions app-dieci/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,19 @@ <h1>
<div id="NameDiv">

</div>
<div></div>
<br />
<div>
<button type="button" id="retrievePod">Prova a verificare quale Pod rispondere alla tua richiesta HTTP! </button>
</div>
<br />
<div id="PodDiv">

</div>
<br />
<div>
<button type="button" id="generateLoad">Genera del carico sulla CPU della tua applicazione! </button>
</div>
<div></div>
<br />
<div>
<button type="button" id="breakPod">Comprometti lo stato del Pod della tua applicazione! </button>
</div>
Expand Down
30 changes: 28 additions & 2 deletions app-dieci/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ function init(){
document.getElementById("retrieveName").onclick = loadName;
document.getElementById("breakPod").onclick = breakPod;
document.getElementById("generateLoad").onclick = generateLoad;
document.getElementById("retrievePod").onclick = loadPod;
}

function loadName(){
Expand All @@ -11,14 +12,29 @@ function loadName(){
if (this.readyState == 4 && this.status == 200) {
let responseObject = JSON.parse(xhttp.responseText);
developerName = responseObject.developerName;
render();
renderName();
}
};

xhttp.open("GET", "developer-name", true);
xhttp.send();
}

function loadPod(){
let xhttp = new XMLHttpRequest();

xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
let responseObject = JSON.parse(xhttp.responseText);
podName = responseObject.podName;
renderPod();
}
};

xhttp.open("GET", "pod-name", true);
xhttp.send();
}

function breakPod(){
let xhttp = new XMLHttpRequest();

Expand All @@ -34,12 +50,22 @@ function generateLoad(){
setTimeout(generateLoad, 5000)
}

function render(){
function renderName(){
let content = "";
content += `
<div>
<p> Che grande Sviluppatore che sei ${developerName} !!</p>
</div>
`
document.getElementById("NameDiv").innerHTML = content;
}

function renderPod(){
let content = "";
content += `
<div>
<p> Ti ha risposto il Pod ${podName} !!</p>
</div>
`
document.getElementById("PodDiv").innerHTML = content;
}
8 changes: 8 additions & 0 deletions app-dieci/src/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
hostName = "0.0.0.0"
serverPort = int(os.environ.get('SERVER_PORT', '8000'))
developerName = os.environ.get('DEVELOPER_NAME', "Davide")
podName = os.environ.get('POD_NAME', "Nome Pod non trovato")
status = { "code": 200, "healthy": "OK"}


Expand Down Expand Up @@ -70,6 +71,13 @@ def do_GET(self):
self.wfile.write(json.dumps(content).encode())
for i in range(0,10000000):
a = math.sqrt(64*64*64*64*64)
case "/pod-name":
self.send_response(200)
self.send_header("Content-type", "application/json")
self.end_headers()
content = {}
content['podName'] = podName
self.wfile.write(json.dumps(content).encode())
case _:
self.send_response(404)
return
Expand Down
12 changes: 10 additions & 2 deletions app-due/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,19 @@ <h1>
<div id="NameDiv">

</div>
<div></div>
<br />
<div>
<button type="button" id="retrievePod">Prova a verificare quale Pod rispondere alla tua richiesta HTTP! </button>
</div>
<br />
<div id="PodDiv">

</div>
<br />
<div>
<button type="button" id="generateLoad">Genera del carico sulla CPU della tua applicazione! </button>
</div>
<div></div>
<br />
<div>
<button type="button" id="breakPod">Comprometti lo stato del Pod della tua applicazione! </button>
</div>
Expand Down
30 changes: 28 additions & 2 deletions app-due/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ function init(){
document.getElementById("retrieveName").onclick = loadName;
document.getElementById("breakPod").onclick = breakPod;
document.getElementById("generateLoad").onclick = generateLoad;
document.getElementById("retrievePod").onclick = loadPod;
}

function loadName(){
Expand All @@ -11,14 +12,29 @@ function loadName(){
if (this.readyState == 4 && this.status == 200) {
let responseObject = JSON.parse(xhttp.responseText);
developerName = responseObject.developerName;
render();
renderName();
}
};

xhttp.open("GET", "developer-name", true);
xhttp.send();
}

function loadPod(){
let xhttp = new XMLHttpRequest();

xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
let responseObject = JSON.parse(xhttp.responseText);
podName = responseObject.podName;
renderPod();
}
};

xhttp.open("GET", "pod-name", true);
xhttp.send();
}

function breakPod(){
let xhttp = new XMLHttpRequest();

Expand All @@ -34,12 +50,22 @@ function generateLoad(){
setTimeout(generateLoad, 5000)
}

function render(){
function renderName(){
let content = "";
content += `
<div>
<p> Che grande Sviluppatore che sei ${developerName} !!</p>
</div>
`
document.getElementById("NameDiv").innerHTML = content;
}

function renderPod(){
let content = "";
content += `
<div>
<p> Ti ha risposto il Pod ${podName} !!</p>
</div>
`
document.getElementById("PodDiv").innerHTML = content;
}
8 changes: 8 additions & 0 deletions app-due/src/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
hostName = "0.0.0.0"
serverPort = int(os.environ.get('SERVER_PORT', '8000'))
developerName = os.environ.get('DEVELOPER_NAME', "Davide")
podName = os.environ.get('POD_NAME', "Nome Pod non trovato")
status = { "code": 200, "healthy": "OK"}


Expand Down Expand Up @@ -70,6 +71,13 @@ def do_GET(self):
self.wfile.write(json.dumps(content).encode())
for i in range(0,10000000):
a = math.sqrt(64*64*64*64*64)
case "/pod-name":
self.send_response(200)
self.send_header("Content-type", "application/json")
self.end_headers()
content = {}
content['podName'] = podName
self.wfile.write(json.dumps(content).encode())
case _:
self.send_response(404)
return
Expand Down
12 changes: 10 additions & 2 deletions app-nove/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,19 @@ <h1>
<div id="NameDiv">

</div>
<div></div>
<br />
<div>
<button type="button" id="retrievePod">Prova a verificare quale Pod rispondere alla tua richiesta HTTP! </button>
</div>
<br />
<div id="PodDiv">

</div>
<br />
<div>
<button type="button" id="generateLoad">Genera del carico sulla CPU della tua applicazione! </button>
</div>
<div></div>
<br />
<div>
<button type="button" id="breakPod">Comprometti lo stato del Pod della tua applicazione! </button>
</div>
Expand Down
30 changes: 28 additions & 2 deletions app-nove/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ function init(){
document.getElementById("retrieveName").onclick = loadName;
document.getElementById("breakPod").onclick = breakPod;
document.getElementById("generateLoad").onclick = generateLoad;
document.getElementById("retrievePod").onclick = loadPod;
}

function loadName(){
Expand All @@ -11,14 +12,29 @@ function loadName(){
if (this.readyState == 4 && this.status == 200) {
let responseObject = JSON.parse(xhttp.responseText);
developerName = responseObject.developerName;
render();
renderName();
}
};

xhttp.open("GET", "developer-name", true);
xhttp.send();
}

function loadPod(){
let xhttp = new XMLHttpRequest();

xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
let responseObject = JSON.parse(xhttp.responseText);
podName = responseObject.podName;
renderPod();
}
};

xhttp.open("GET", "pod-name", true);
xhttp.send();
}

function breakPod(){
let xhttp = new XMLHttpRequest();

Expand All @@ -34,12 +50,22 @@ function generateLoad(){
setTimeout(generateLoad, 5000)
}

function render(){
function renderName(){
let content = "";
content += `
<div>
<p> Che grande Sviluppatore che sei ${developerName} !!</p>
</div>
`
document.getElementById("NameDiv").innerHTML = content;
}

function renderPod(){
let content = "";
content += `
<div>
<p> Ti ha risposto il Pod ${podName} !!</p>
</div>
`
document.getElementById("PodDiv").innerHTML = content;
}
8 changes: 8 additions & 0 deletions app-nove/src/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
hostName = "0.0.0.0"
serverPort = int(os.environ.get('SERVER_PORT', '8000'))
developerName = os.environ.get('DEVELOPER_NAME', "Davide")
podName = os.environ.get('POD_NAME', "Nome Pod non trovato")
status = { "code": 200, "healthy": "OK"}


Expand Down Expand Up @@ -70,6 +71,13 @@ def do_GET(self):
self.wfile.write(json.dumps(content).encode())
for i in range(0,10000000):
a = math.sqrt(64*64*64*64*64)
case "/pod-name":
self.send_response(200)
self.send_header("Content-type", "application/json")
self.end_headers()
content = {}
content['podName'] = podName
self.wfile.write(json.dumps(content).encode())
case _:
self.send_response(404)
return
Expand Down
12 changes: 10 additions & 2 deletions app-otto/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,19 @@ <h1>
<div id="NameDiv">

</div>
<div></div>
<br />
<div>
<button type="button" id="retrievePod">Prova a verificare quale Pod rispondere alla tua richiesta HTTP! </button>
</div>
<br />
<div id="PodDiv">

</div>
<br />
<div>
<button type="button" id="generateLoad">Genera del carico sulla CPU della tua applicazione! </button>
</div>
<div></div>
<br />
<div>
<button type="button" id="breakPod">Comprometti lo stato del Pod della tua applicazione! </button>
</div>
Expand Down
Loading

0 comments on commit 9096314

Please sign in to comment.