Skip to content

Instantly share code, notes, and snippets.

View robertcoopercode's full-sized avatar

Robert Cooper robertcoopercode

View GitHub Profile
// 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 =
[
// 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);
// 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();
});
// 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();
// 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
<html>
<head>
<link href="styles.css" rel="stylesheet" text="text/css" />
</head>
<body>
<h1 class="title">Lorem Ipsum Generator</h1>
// 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;
.button {
background-color: blue;
color: white;
&:hover {
background-color: lightblue;
}
}
.button {
background-color: blue;
color: white;
}
.button:hover {
background-color: lightblue;
}
.container {
width: 100%;
}
article[role="main"] {
float: left;
width: 62.5%;
}
aside[role="complementary"] {