Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

done #3008

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

done #3008

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const express = require('express');
const axios = require('axios')

const hbs = require('hbs');
const path = require('path');
Expand All @@ -19,7 +20,25 @@ app.use(express.static(path.join(__dirname, 'public')));
// Add the route handlers here:

app.get('/', (req, res) => {
res.render('index');
res.render('home');
});

app.get('/beers', (req, res) => {
axios.get('https://api.openbrewerydb.org/v1/breweries')
.then((response)=>{
console.log('response', response.data)
res.render('beers', {id: response.data})
})
.catch((err)=>console.log(err))
});

app.get('/random-beers', (req, res) => {
axios.get('https://api.openbrewerydb.org/v1/breweries/random')
.then((response)=>{
console.log('response', response.data)
res.render('random-beers', {id: response.data})
})
.catch((err)=>console.log(err))
});

app.listen(3000, () => console.log('🏃‍ on port 3000'));
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
},
"license": "ISC",
"dependencies": {
"express": "^4.17.1",
"axios": "^1.7.2",
"express": "^4.19.2",
"hbs": "^4.1.1",
"punkapi-javascript-wrapper": "^1.0.2"
}
Expand Down
65 changes: 65 additions & 0 deletions public/stylesheets/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,68 @@ dark-blue: #0a2c42;
grey: #bfbfbf;
font-family: Arial, Helvetica, sans-serif;
*/

body{
margin: 0;
}
nav{
background-color: #2081c3;
color: white;
width: 100%;
height: 4rem;
position: fixed;
top: 0;
display: flex;
align-items: center;
}
.nav-ul{
margin: 0;
display: flex;
align-items: center;
}
.nav-li{
margin-left: 20px;
list-style-type: none;
}
.nav-a{
text-decoration: none;
color: white;
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

.home-container{
margin-top: 7rem;
display: flex;
flex-direction: column;
align-items: center;
}

.beer-image{
width: 30rem;
text-align: center;
margin-bottom: 20px;
}

.home-a{
margin-top: 10px;
padding: 10px 25px;
background-color: #2081c3;
color: white;
text-decoration: none;
border-radius: 5px;
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

.container{
margin-top: 7rem;
}

.beer-container{
margin: 2rem 1rem;
list-style-type: none;
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

.beer-li1{
font-weight: bold;
}
13 changes: 13 additions & 0 deletions views/beers.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

<div class="container">
{{#each id}}
<ul class="beer-container">
<li class="beer-li1">Brewery Name: {{name}}</li>
<li class="beer-li">Brewery Type: {{brewery_type}}</li>
<li class="beer-li">City: {{city}}</li>
<li class="beer-li">Country: {{country}}</li>
<li class="beer-li">Phone: {{phone}}</li>
<li class="beer-li">Website: <a href="{{website_url}}">{{name}}</a></li>
</ul>
{{/each}}
</div>
5 changes: 5 additions & 0 deletions views/home.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div class="home-container">
<img src="/images/beer.png" alt="a mug of beer" class="beer-image">
<a href="/beers" class="home-a">Click the Beers!</a>
<a href="/random-beers" class="home-a">Click a Random Beer!</a>
</div>
3 changes: 0 additions & 3 deletions views/index.hbs

This file was deleted.

19 changes: 19 additions & 0 deletions views/layout.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/stylesheets/styles.css">
<title>Document</title>
</head>
<body>
<nav>
<ul class="nav-ul">
<li class="nav-li"><a href="/" class="nav-a">Home</a></li>
<li class="nav-li"><a href="/beers" class="nav-a">Beers</a></li>
<li class="nav-li"><a href="/random-beers" class="nav-a">Random Beers</a></li>
</ul>
</nav>
{{{ body }}}
</body>
</html>
Empty file added views/partials/partials.hbs
Empty file.
13 changes: 13 additions & 0 deletions views/random-beers.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

<div class="container">
{{#each id}}
<ul class="beer-container">
<li class="beer-li1">Brewery Name: {{name}}</li>
<li class="beer-li">Brewery Type: {{brewery_type}}</li>
<li class="beer-li">City: {{city}}</li>
<li class="beer-li">Country: {{country}}</li>
<li class="beer-li">Phone: {{phone}}</li>
<li class="beer-li">Website: <a href="{{website_url}}">{{name}}</a></li>
</ul>
{{/each}}
</div>