From a227b062bc734fe1a22fb7f1a4cad03ed01c2e1d Mon Sep 17 00:00:00 2001 From: Antonia Rubell Date: Wed, 26 Jun 2024 21:08:37 +0300 Subject: [PATCH 1/2] rename header --- project/html/pages/index.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/html/pages/index.ejs b/project/html/pages/index.ejs index 7e8a0900..9b9ebd45 100644 --- a/project/html/pages/index.ejs +++ b/project/html/pages/index.ejs @@ -9,7 +9,7 @@

Click on the button for a surprise.

From 02b778e9d579d067cc4e144dde99040e98231025 Mon Sep 17 00:00:00 2001 From: Antonia Rubell Date: Fri, 28 Jun 2024 00:25:33 +0300 Subject: [PATCH 2/2] lotsa stuff --- project/html/helpers/head.ejs | 2 ++ project/html/helpers/navbar.ejs | 5 +++++ project/html/pages/album.ejs | 24 ++++++++++++++++++++++++ project/html/pages/history.ejs | 27 +++++++++++++++++++++++++++ project/html/pages/index.ejs | 2 +- project/js/main.js | 27 +++++++++++++++++++++++++++ project/start.js | 9 +++++++++ requirements.txt | 1 + 8 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 project/html/helpers/navbar.ejs create mode 100644 project/html/pages/album.ejs create mode 100644 project/html/pages/history.ejs create mode 100644 requirements.txt diff --git a/project/html/helpers/head.ejs b/project/html/helpers/head.ejs index d40b02e2..43baa6a6 100644 --- a/project/html/helpers/head.ejs +++ b/project/html/helpers/head.ejs @@ -23,5 +23,7 @@ + + diff --git a/project/html/helpers/navbar.ejs b/project/html/helpers/navbar.ejs new file mode 100644 index 00000000..ff6ac6f7 --- /dev/null +++ b/project/html/helpers/navbar.ejs @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/project/html/pages/album.ejs b/project/html/pages/album.ejs new file mode 100644 index 00000000..2bcebbe4 --- /dev/null +++ b/project/html/pages/album.ejs @@ -0,0 +1,24 @@ + + + <% include ../helpers/head %> + + + + + + + +

Click on the button for a surprise.

+ + + +
+ + + + \ No newline at end of file diff --git a/project/html/pages/history.ejs b/project/html/pages/history.ejs new file mode 100644 index 00000000..488b4a06 --- /dev/null +++ b/project/html/pages/history.ejs @@ -0,0 +1,27 @@ + + + <% include ../helpers/head %> + + + + + + + + + + +
+ +
+ +
+ + + + \ No newline at end of file diff --git a/project/html/pages/index.ejs b/project/html/pages/index.ejs index 9b9ebd45..157c9f2a 100644 --- a/project/html/pages/index.ejs +++ b/project/html/pages/index.ejs @@ -7,7 +7,7 @@ diff --git a/project/js/main.js b/project/js/main.js index c045cac2..e227a0c5 100644 --- a/project/js/main.js +++ b/project/js/main.js @@ -1,3 +1,30 @@ +$(document).ready(function(){ + getWeather(); +}) + +function getWeather(searchQuery) { + // var url = "https://api.openweathermap.org/data/2.5/weather?q=Boston&APPID="+apiKey; // Need to figure out how to make sure Heroku is storing my API key + + var url = "https://api.openweathermap.org/data/2.5/weather?q="+searchQuery+"&units=imperial&APPID=de7c147ddb0ac76a8ca839042b94c47a" + + $(".city").text(""); + $(".temp").text(""); + $(".error-message").text(""); + + $.ajax(url,{success: function(data){ + $(".city").text(data.name); + $(".temp").text(data.main.temp); + // console.log(data); // To view in the console log + }, error: function(error){ + $(".error-message").text("An error occurred"); + }}) +} + +function searchWeather() { + var searchQuery = $(".search").val(); + getWeather(searchQuery); +} + function showPicture(){ // use jQuery ($ is shorthand) to find the div on the page and then change the html // 'rounded-circle' is a bootstrap thing! Check out more here: http://getbootstrap.com/css/ diff --git a/project/start.js b/project/start.js index bbe5c402..11ee91b8 100644 --- a/project/start.js +++ b/project/start.js @@ -13,6 +13,15 @@ app.get('/', function(request, response) { response.render('pages/index'); }); +app.get('/album', function(request, response) { + response.render('pages/album'); +}); + +app.get('/history', function(request, response) { + response.render('pages/history'); +}); + + app.listen(app.get('port'), function() { console.log('Node app is running on port', app.get('port')); }); diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..fd7d3e06 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +requests==2.25.1 \ No newline at end of file