博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[Node.js]25. Level 5. Route params
阅读量:4577 次
发布时间:2019-06-08

本文共 928 字,大约阅读时间需要 3 分钟。

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 did in previous levels (and then close the response).

var express = require('express');var app = express.createServer();var quotes = {  'einstein': 'Life is like riding a bicycle. To keep your balance you must keep moving',  'berners-lee': 'The Web does not just connect machines, it connects people',  'crockford': 'The good thing about reinventing the wheel is that you can get a round one',  'hofstadter': 'Which statement seems more true: (1) I have a brain. (2) I am a brain.'};app.get('/quotes/:name', function(request, response){    var quote = quotes[request.params.name];      response.end(quote);});app.listen(8080);

 

转载于:https://www.cnblogs.com/Answer1215/p/3881125.html

你可能感兴趣的文章
前端验证 validform
查看>>
分布式计算
查看>>
《debug unreal engine code》
查看>>
RocketMQ之双Master方式部署以及简单使用
查看>>
现身说法:面对DDoS攻击时该如何防御?
查看>>
C的动态链表建立
查看>>
source insight 不能添加cc文件
查看>>
NYOJ 16 矩形嵌套
查看>>
Leetcode中的SQL题目练习(二)
查看>>
dubbo 集群容错源码
查看>>
Collection接口的子接口——Queue接口
查看>>
LINUX安装NGINX
查看>>
服务器启动项目抛错 没有到主机的路由
查看>>
python_85_sys模块
查看>>
第九周动手动脑
查看>>
HDU 1811 Rank of Tetris
查看>>
网站UI分析
查看>>
winform 获取当前名称
查看>>
报表分栏后的排序
查看>>
Django中models定义的choices字典使用get_FooName_display()在页面中显示值
查看>>