This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Code that generates the random lorem ipsum text | |
// Create a new object called loremIpsum by invoking the GenerateNewText constructor function | |
const loremIpsum = new GenerateNewText(); | |
// Constructor function that creates an object with the sentences property | |
function GenerateNewText() { | |
// Add property to the object | |
this.sentences = | |
[ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Route that generates the lorem ipsum text and reloads a modified index.html | |
router.post('/', (request, response) => { | |
request.on("data", function(inputValue) { | |
// Convert the POST data into a readable string | |
let query = inputValue.toString(); // i.e. numberOfParagraphs=3 | |
// Parse the query into a key/value pair and store the value of numberOfParagraphs | |
// in a variable | |
let numberOfParagraphs = querystring.parse(query).numberOfParagraphs; | |
// Generate the lorem ipsum text with the getAllParagraphs function | |
let loremIpsumText = loremIpsum.getAllParagraphs(numberOfParagraphs); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Route that serves index.html | |
router.get('/', (request, response) => { | |
response.setHeader('Content-Type', 'text/html'); | |
// Capture the contents of index.html in a variable | |
let fileContents = fs.readFileSync("./public/index.html", {encoding: "utf8"}); | |
// Send a response to the client with the index.html file | |
response.write(fileContents); | |
response.end(); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Require the necessary modules | |
const loremIpsum = require("./generator.js"); | |
const querystring = require("querystring"); | |
const fs = require("fs"); | |
// Require express and create an express router object | |
const express = require('express'); | |
const router = express.Router(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Require the necessary modules | |
const loremIpsum = require("./generator.js"); | |
const querystring = require("querystring"); | |
const fs = require("fs"); | |
// Require express and create an express router object | |
const express = require('express'); | |
const router = express.Router(); | |
// Route that serves index.html |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<link href="styles.css" rel="stylesheet" text="text/css" /> | |
</head> | |
<body> | |
<h1 class="title">Lorem Ipsum Generator</h1> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Require express and create an express application instance | |
const express = require('express'); | |
const app = express(); | |
// Require the express routes defined in router.js | |
const routes = require('./router'); | |
// Define the hostname and port where the server can be found | |
const hostname = "127.0.0.1"; | |
const port = 3000; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.button { | |
background-color: blue; | |
color: white; | |
&:hover { | |
background-color: lightblue; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.button { | |
background-color: blue; | |
color: white; | |
} | |
.button:hover { | |
background-color: lightblue; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.container { | |
width: 100%; | |
} | |
article[role="main"] { | |
float: left; | |
width: 62.5%; | |
} | |
aside[role="complementary"] { |