Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoOMaia committed Nov 26, 2023
1 parent b72c63d commit ea03fea
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Rodar ``server.py``, depois rodar ``client.py`` desse jeito: ``python client.py
## Testando REST_API/Usando recomendador de musica
use port-forward para acessar o cluster em PORTS
```
adicione <ip cluster>:32197
adicione <ip cluster>:32208
```

## Acessando o ArgoCD
Expand Down
2 changes: 1 addition & 1 deletion Rest_API/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ def get_songs():
return jsonify({'songs': songs_data})

if __name__ == '__main__':
app.run(port=32197, host="0.0.0.0")
app.run(port=32208, host="0.0.0.0")
29 changes: 27 additions & 2 deletions Rest_API/static/scripts.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
let allSongsList = [];

let URL = 'http://localhost:32197';
let URL = 'http://localhost:32208';

fetch(URL + '/api/songs')
.then(response => {
Expand Down Expand Up @@ -117,9 +117,34 @@ function hideNoRecommendationsMessage() {
noRecommendationsMessage.style.display = "none";
}


function displayRecommendations(recommendations) {
const recommendedList = document.getElementById("recommendedPlaylists");

recommendedList.innerHTML = "";

recommendations.forEach(recommendation => {
const listItem = document.createElement("li");
const songLink = document.createElement("a");

songLink.textContent = recommendation;
songLink.href = `https://www.google.com/search?q=${encodeURIComponent(recommendation)}+song`;
songLink.setAttribute("target", "_blank");
songLink.style.color = "black";

songLink.addEventListener("click", (event) => {
event.preventDefault();
window.open(songLink.href, '_blank');
});

listItem.appendChild(songLink);
recommendedList.appendChild(listItem);
});
}

document.getElementById("findPlaylistBtn").addEventListener("click", async () => {
try {
const response = await fetch('http://localhost:32197/api/recommend', {
const response = await fetch(URL + '/api/recommend', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
Expand Down
2 changes: 0 additions & 2 deletions Train_model/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,4 @@ COPY . /app

RUN pip install -r requirements.txt

EXPOSE 32208

CMD python ml.py
2 changes: 0 additions & 2 deletions kubernetes/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ spec:
image: leoomaia/ml_cloud
imagePullPolicy: Always
restartPolicy: OnFailure
ports:
- containerPort: 32208
volumeMounts:
- name: persistent-volume
mountPath: /app/models
Expand Down
4 changes: 2 additions & 2 deletions kubernetes/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ spec:
app: playlist-recommender
ports:
- protocol: TCP
port: 8008
targetPort: 8008
port: 32196
targetPort: 32196

0 comments on commit ea03fea

Please sign in to comment.