[Node.js]28. Level 5: Express Server
2023-09-14 09:00:56 时间
Now let's create an express server which queries out for this search term and just returns the json. You'll need to do a few things:
- Require the express module
- Create the express server 'app'
- On a get request to '/', pipe the
request(searchURL)
to the response. - Tell the app to listen on port 8080
var url = require('url'); var request = require('request'); var express = require('express'); options = { protocol: "http:", host: "search.twitter.com", pathname: '/search.json', query: { q: "codeschool"} }; var searchURL = url.format(options); var app = express.createServer(); app.get('/', function(req, response){ request(searchURL).pipe(response); }); app.listen(8080);
相关文章
- js的alert和confirm美化
- [Node.js] Show More Lines in a Node.js Error Stack Trace
- [Ramada] Build a Functional Pipeline with Ramda.js
- js es6 标签模板还原字符串
- Node.js is only supported on Windows 8.1, Windows Server 2012 R2, or higher
- [Nuxt] Setup a "Hello World" Server-Rendered Vue.js Application with the Vue-CLI and Nuxt
- [Immutable.js] Transforming Immutable Data with Reduce
- [Node.js]29. Level 6: Socket.io: Setting up Socket.io server-side & Client socket.io setup
- js小案例:使用location.href自动跳转页面
- sap-ui-core.js reference in Webclient ui
- js保留6位小数,转成数字
- 第37篇 QML中导入定义的JS文件
- 初识node.js
- js的++,--
- js 实现元素拖拽
- leetcode 3. 无重复字符的最长子串 js 实现
- js-jquery-Validate校验【二】中文api
- 利用js_API 运行对html文档元素的属性的CRUD操作
- JS json字符串转换