Homework 8 Completion

++ Homework 8 Files
+- Modified server.js
This commit is contained in:
Charles Descamps 2023-04-10 21:37:40 -07:00
parent 60087976ca
commit 0f2b3d0ef8
3 changed files with 150 additions and 2 deletions

View file

@ -0,0 +1,37 @@
<!DOCTYPE html>
<html>
<head>
<title>Homework 8 - Mad Libs Recipe</title>
<style>
@import url("/cs212/homework/8/styles.css");
</style>
</head>
<body>
<h1>Mad Libs Recipe: A souper great one!</h1>
<form id="madLibs" method="POST">
<label for="ingredientOneInput">Any ingredient:</label>
<input type="text" id="ingredientOneInput" name="ingredientOne">
<br>
<label for="ingredientTwoInput">Broth:</label>
<input type="text" id="ingredientTwoInput" name="ingredientTwo">
<br>
<label for="ingredientThreeInput">Whole Vegetables (Plural):</label>
<input type="text" id="ingredientThreeInput" name="ingredientThree">
<br>
<label for="ingredientFourInput">Vegetable:</label>
<input type="text" id="ingredientFourInput" name="ingredientFour">
<br>
<label for="ingredientFiveInput">Vegetable:</label>
<input type="text" id="ingredientFiveInput" name="ingredientFive">
<br>
<label for="ingredientSixInput">Protein/Meat:</label>
<input type="text" id="ingredientSixInput" name="ingredientSix">
<br>
<label for="ingredientSevenInput">Seasoning:</label>
<input type="text" id="ingredientSevenInput" name="ingredientSeven">
<br>
<input type="submit" value="Generate Mad Lib!">
</form>
<div id="generatedLib"></div>
</body>
</html>

View file

@ -0,0 +1,94 @@
/* Ubuntu - cyrillic-ext */
@font-face {
font-family: 'Ubuntu';
font-style: normal;
font-weight: 400;
font-display: swap;
src: url(https://fonts.gstatic.com/s/ubuntu/v20/4iCs6KVjbNBYlgoKcg72j00.woff2) format('woff2');
unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
/* Ubuntu - cyrillic */
@font-face {
font-family: 'Ubuntu';
font-style: normal;
font-weight: 400;
font-display: swap;
src: url(https://fonts.gstatic.com/s/ubuntu/v20/4iCs6KVjbNBYlgoKew72j00.woff2) format('woff2');
unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
/* Ubuntu - greek-ext */
@font-face {
font-family: 'Ubuntu';
font-style: normal;
font-weight: 400;
font-display: swap;
src: url(https://fonts.gstatic.com/s/ubuntu/v20/4iCs6KVjbNBYlgoKcw72j00.woff2) format('woff2');
unicode-range: U+1F00-1FFF;
}
/* Ubuntu - greek */
@font-face {
font-family: 'Ubuntu';
font-style: normal;
font-weight: 400;
font-display: swap;
src: url(https://fonts.gstatic.com/s/ubuntu/v20/4iCs6KVjbNBYlgoKfA72j00.woff2) format('woff2');
unicode-range: U+0370-03FF;
}
/* Ubuntu - latin-ext */
@font-face {
font-family: 'Ubuntu';
font-style: normal;
font-weight: 400;
font-display: swap;
src: url(https://fonts.gstatic.com/s/ubuntu/v20/4iCs6KVjbNBYlgoKcQ72j00.woff2) format('woff2');
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* Ubuntu - latin */
@font-face {
font-family: 'Ubuntu';
font-style: normal;
font-weight: 400;
font-display: swap;
src: url(https://fonts.gstatic.com/s/ubuntu/v20/4iCs6KVjbNBYlgoKfw72.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* CowboyBebopFontStyle */
@font-face {
font-family: 'Bebop';
font-style: normal;
font-weight: 700;
font-display: swap;
src: url('/fonts/CheltenhamStdBoldCondIt.woff') format('woff');
}
/* CSS Styles for headers 1-4 and paragraph tags. */
h1 {font-family: 'Bebop', serif;}
h2 {font-family: 'Bebop', serif;}
h3 {font-family: 'Bebop', serif;}
h4 {font-family: 'Ubuntu', sans-serif;}
p {font-family: 'Ubuntu', sans-serif; padding:0.3em 1em;}
/* CSS Styling for the ID sector */
#sector {
text-align: center;
color: #003466;
}
.mainPage {
display: grid;
grid-template: auto 1fr auto / auto 1fr auto;
}
header {
padding: 2rem;
grid-column: 1 / 4;
}
.menuBar {
grid-column: 1 / 2;
}
main {
grid-column: 2 / 3;
}
.adBar {
grid-column: 3 / 4;
}
footer {
padding: 1rem;
grid-column: 1 / 4;
}

View file

@ -10,6 +10,23 @@ server.get('/do_a_random', (req, res) => {
res.send(`Your number is: ${Math.floor(Math.random() * 100) + 1}`)
})
server.post("/cs212/homework/8/index.html", (req, res) => {
// Retrieve form data from request body
ingredientOneInput = req.body.ingredientOne;
ingredientTwoInput = req.body.ingredientTwo;
ingredientThreeInput = req.body.ingredientThree;
ingredientFourInput = req.body.ingredientFour;
ingredientFiveInput = req.body.ingredientFive;
ingredientSixInput = req.body.ingredientSix;
ingredientSevenInput = req.body.ingredientSeven;
// Create mad lib string
madLib = `A throw together soup consisting of: One cup of ${ingredientOneInput}, Five cups of ${ingredientTwoInput}, Two ${ingredientThreeInput}, 1/2 cup of ${ingredientFourInput}, One large ${ingredientFiveInput}, 1/4 pound of ${ingredientSixInput}, and ${ingredientSevenInput} to taste`;
// Send mad lib as response
res.send(madLib);
});
// Setup static page serving for all the pages in "public"
const publicServedFilesPath = path.join(__dirname, 'public')
@ -19,9 +36,9 @@ server.use(express.static(publicServedFilesPath))
// The server uses port 80 by default unless you start it with the extra
// command line argument 'local' like this:
// node server.js local
let port = 80
let port = 8191
if (process.argv[2] === 'local') {
port = 8080
port = 80
}
server.listen(port, () => console.log('Ready on localhost!'))