Skip to content

Commit

Permalink
Week 6 Homework
Browse files Browse the repository at this point in the history
Week 6 Homework
  • Loading branch information
caitycroft committed Oct 18, 2023
1 parent ec5cb49 commit c702fde
Show file tree
Hide file tree
Showing 874 changed files with 124,767 additions and 13 deletions.
Binary file modified .DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,17 +1,64 @@
{
"samples": [
{ "filename": "KICK 1.wav" , "class": "kick", "id":"audio_techno_vibe_1_kick"},
{ "filename": "GROOVE 1.wav", "class": "groove", "id":"audio_techno_vibe_1_groove"},
{ "filename": "BASS 1.wav", "class": "bass", "id":"audio_techno_vibe_1_bass"},
{ "filename": "KICK 2.wav" , "class": "kick", "id":"audio_techno_vibe_2_kick"},
{ "filename": "GROOVE 2.wav", "class": "groove", "id":"audio_techno_vibe_2_groove"},
{ "filename": "BASS 2.wav", "class": "bass", "id":"audio_techno_vibe_2_bass"},
{ "filename": "KICK 3.wav" , "class": "kick", "id":"audio_techno_vibe_3_kick"},
{ "filename": "GROOVE 3.wav", "class": "groove", "id":"audio_techno_vibe_3_groove" },
{ "filename": "BASS 3.wav", "class": "bass", "id":"audio_techno_vibe_3_bass" },
{ "filename": "KICK 4.wav" , "class": "kick", "id":"audio_techno_vibe_4_kick"},
{ "filename": "GROOVE 4.wav", "class": "groove", "id":"audio_techno_vibe_4_groove" },
{ "filename": "BASS 4.wav", "class": "bass", "id":"audio_techno_vibe_4_bass" }
{
"filename": "KICK 1.wav",
"class": "kick",
"id": "audio_techno_vibe_1_kick"
},
{
"filename": "GROOVE 1.wav",
"class": "groove",
"id": "audio_techno_vibe_1_groove"
},
{
"filename": "BASS 1.wav",
"class": "bass",
"id": "audio_techno_vibe_1_bass"
},
{
"filename": "KICK 2.wav",
"class": "kick",
"id": "audio_techno_vibe_2_kick"
},
{
"filename": "GROOVE 2.wav",
"class": "groove",
"id": "audio_techno_vibe_2_groove"
},
{
"filename": "BASS 2.wav",
"class": "bass",
"id": "audio_techno_vibe_2_bass"
},
{
"filename": "KICK 3.wav",
"class": "kick",
"id": "audio_techno_vibe_3_kick"
},
{
"filename": "GROOVE 3.wav",
"class": "groove",
"id": "audio_techno_vibe_3_groove"
},
{
"filename": "BASS 3.wav",
"class": "bass",
"id": "audio_techno_vibe_3_bass"
},
{
"filename": "KICK 4.wav",
"class": "kick",
"id": "audio_techno_vibe_4_kick"
},
{
"filename": "GROOVE 4.wav",
"class": "groove",
"id": "audio_techno_vibe_4_groove"
},
{
"filename": "BASS 4.wav",
"class": "bass",
"id": "audio_techno_vibe_4_bass"
}
]

}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
console.log("This is my server file.");

//Data
let astronauts = {
"data": [
{
"key": "lindgren",
"name": "Kjell Lindgren",
"craft": "ISS",
"wikipedia": "https://en.wikipedia.org/wiki/Kjell_N._Lindgren"
},
{
"key": "hines",
"name": "Bob Hines",
"craft": "ISS",
"wikipedia": "https://en.wikipedia.org/wiki/Robert_Hines_(astronaut)"
},
{
"key": "yang",
"name": "Liu Yang",
"craft": "Tiangong",
"wikipedia": "https://en.wikipedia.org/wiki/Liu_Yang_(taikonaut)"
}
]
};

//5. Require Express
let express = require('express');
console.log(express);

//6. Create an app object
let app = express();
console.log(app);

//7. Create a Route
app.get('/', (request, response) => {
response.send("This is the main page");
});

//8. Listen
app.listen(3000, () => {
console.log('The server is listening on localhost:3000');
});

//9. Create additional routes

app.get('/about', (request, response) => {
//response.send("This is my Astronauts page");
});

app.get('/astronauts', (request, response) => {
//response.send("This is my Astronauts page");
});


app.get('/astronauts/:astronaut', (request, response) => {
let astronaut = request.params.astronaut;
let astronaut_obj; // will hold the value that we'll send back to the client
for (let i = 0; i < astronauts.data.length; i++) {
if (astronaut === astronauts.data[i].key) {
astronaut_obj = astronauts.data[i];
}
}
// console.log(astronaut_obj);

if (astronaut_obj) {
//send back the specific object to the client side
response.json(astronaut_obj);
} else {
response.json({ "status": "Data doesn't exist" });
}

});

//Step 12. Serve static files
app.use('/', express.static('public'));

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c702fde

Please sign in to comment.