
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
Change the node server code by adding some instructions:
const express = require('express');
const dotenv = require('dotenv');
dotenv.config();
const app = express();
app.get('/dotted', (req, res) => {
const { word1, word2 } = req.query;
const dots = '.'.repeat(30 - word1.length - word2.length);
const result = `<pre>${word1}${dots}${word2}</pre>`;
res.status(200).contentType('text/html').send(result);
});
app.get("/fizzBuzz", (req, res) => {
const start = parseInt(req.query.start);
const end = parseInt(req.query.end);
let response = "";
for (let i = start; i <= end; i++) {
if (i % 3 === 0 && i % 5 === 0) {
response += "FizzBuzz\n";
} else if (i % 3 === 0) {
response += "Fizz\n";
} else if (i % 5 === 0) {
response += "Buzz\n";
} else {
response += `${i}\n`;
}
}
res.contentType("text/html");
res.send(`<pre>${response}</pre>`);
});
app.get('/gradeStats', (req, res) => {
const { grades } = req.query;
const min = Math.min(...grades);
const max = Math.max(...grades);
const avg = (grades.reduce((a, b) => a + b) / grades.length).toFixed(2);
const result = JSON.stringify({ average: avg, minimum: min, maximum: max });
res.status(200).contentType('application/json').send(result);
});
app.get("/rectangle", (req, res) => {
const length = parseInt(req.query.length);
const width = parseInt(req.query.width);
const area = length * width;
const perimeter = 2 * (length + width);
const response = { area, perimeter };
res.contentType("application/json");
res.send(response);
});
const PORT = process.env.PORT || 3000;
const HOST = process.env.HOST || 'localhost';
app.listen(PORT, HOST, () => {
console.log(`Server running at http://${HOST}:${PORT}`);
});
Use Express Session
- Use the session to keep track of:
- How many commands have been executed.
- What the last command executed was.
- Create a middleware function to keep track of this information.
- Add a JSON endpoint: /stats
- It will return responses like: {"commandCount": 3, "lastCommand": "/dotted"}
- Calling /stats will not increment commandCount or change the lastCommand value.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 5 steps with 3 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- BankCustomerQueueADT Implement in C++ a BankCustomer QueueADT that does the following: 1. gets the input about a customer (first name, last name, Bank Account Number, Money to be withdrawn/deposited, etc.) from the user (from the keyboard) 2. inserts (enqueues) the Customer as a record into the BankCustomerQueueADT (your Queue ADT must be able to have a maximum of 20 customer records) 3. removes (dequeues) the Customer record from the BankCustomerQueueADT 4. your BankCustomerQueueADT must also have the behavior of retrieving and displaying the Queue info on the screen after each event (either entry of a Bank Customer into the queue, OR leaving of the Bank customer from the queue). NOTE: Please make sure you debug, run, test and see the program working correctly before submitting. Make sure all the code statements are commented. Make sure your program is indented properly.arrow_forwardJava adt Draw the contents of the queue after the following statements execute. Clearly label the front and back of the queue. QueueInterface bankLine = new LinkedQueue<>(); bankLine .enqueue("John"); bankLine .enqueue("Matthew"); String next = bankLine .dequeue(); next = bankLine .dequeue(); bankLine .enqueue("Drew"); bankLine .enqueue("Heather"); next = bankLine .dequeue(); bankLine .enqueue("David"); next = bankLine .dequeue();arrow_forwardWhen an element is removed from a queue, where is it removed from?arrow_forward
- def upgrade_stations(threshold: int, num_bikes: int, stations: List["Station"]) -> int: """Modify each station in stations that has a capacity that is less than threshold by adding num_bikes to the capacity and bikes available counts. Modify each station at most once. Return the total number of bikes that were added to the bike share network. Precondition: num_bikes >= 0arrow_forwardAttachedarrow_forwardb. Write out the order of elements that are contained in a queue after the following operations are performed. myQueue.enqueue(new Integer(16)); myQueue.enqueue(new Integer(12)); Integer num1 = myQueue.dequeue(); myQueue.enqueue(new Integer(6)); myQueue.enqueue(new Integer(8)); myQueue.enqueue(new Integer(30)); myQueue.enqueue(new Integer(24)); myQueue.enqueue(new Integer(18)); myQueue.dequeue(); myQueue.dequeue(); myQueue.dequeue(); myQueue.enqueue(new Integer(38); Show how step by step process of arriving at your answer.arrow_forward
- Select the statements that apply to the use of the frame pointer. EBP is often called the base pointer or frame pointer because it holds the base address of the stack frame. EBP does not changes value during the procedure. EBP need not be restored to its original value when a procedure returns. A procedure can explicitly access stack parameters using constant offsets from EBP.arrow_forwardhow does the structure if counting semaphore primitives differ frim binary semaphore primitives?arrow_forwarddata МАТH data ENGL null next next top top data MATH next null The above is a stack of textbooks. The top is a node to record the address of the top element of a stack. 2. Which of the following statement push the ENGL textbook to the top? top.next = new Node("ENGL", top); a. b. top = new Node("ENGL", top) Describe the reason of your choice. Your answer is (a or b) Will the push action take time in 0(1) or 0(n)? Next Page O Type here to searcharrow_forward
- What are the chief differences between these three data structures? How can you determine when it is appropriate to use a queue, a dequeue, or a priority queue?arrow_forwardWhat values are returned during the following sequence of queue operations, if executed on an initially empty queue? Enqueue(5) 1. 2. Enqueue(3) 3. Enqueue(2) 4. Dequeuel) 5. Enqueue(1) 6. Dequeuel) 7. Dequeuel) 8. Enqueue(4) 9. Dequeuel) 10. Dequeuel)arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education