[Node.js]25. Level 5. Route params】的更多相关文章

Create a route that responds to a GET request '/quotes/<name>', then use the param from the URL to retrieve a quote from the quotes object and write it out to the response. Note: No piping here, just write the quote string to the response like you d…
Instead of just writing out the quote to the response, instead render the quote.ejs template, passing in the quote name and quote body. Then finish the quote.ejs view, by printing out the quote name and body. var express = require('express'); var app…
Clients can also answer each other questions, so let's build that feature by first listening for the'answer' event on the client, which will send us both the question and answer, which we want to broadcast out to the rest of the connected clients. va…
Create an express route that responds to GET requests at the URL /tweets that responds with the filetweets.html located in the same directory as app.js Make sure you create the app and listen on port 8080 var express = require('express'); var app = e…
Let's start practicing using the redis key-value store from our node application. First require the redismodule, and then create a redis client that we can use to call commands on our redis server. Use the client to set the name key to your name. var…
Below we've already created an express server, but we want to start building a real-time Q&A moderation service and we've decided to use socket.io. Require socket.io and make sure it listens for requests on the express app. Also, print out a message…
Update the versions on your dependencies to be a little more flexible, adding the ~ in front of your versions. package.json { "name": "My Awesome Node App", "version": "1", "dependencies": { "connect&…
Add two dependencies to your package.json file, connect and underscore. You'll want to useconnect version 2.2.1 and underscore version 1.3.3. package.json { "name": "My Awesome Node App", "version": "1", "depen…
Let's go back to our live-moderation app and add some persistence, first to the questions people ask. Use the lpush command to add new questions to the list named questions. Do this inside thequestion listener. var express = require('express'); var a…
As we saw in the video, redis can do more than just simple key-value pairs. We are going to be using redis lists later to add persistance to our live-moderation app, so let's practice using them now. Using the redis client's lpush command, insert the…