[Node.js]28. Level 5: Express Server
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);
[Node.js]28. Level 5: Express Server的更多相关文章
- [Node.js]24. Level 5: Express, Express routes
Create an express route that responds to GET requests at the URL /tweets that responds with the file ...
- Node.js 从零开发 web server博客项目[express重构博客项目]
web server博客项目 Node.js 从零开发 web server博客项目[项目介绍] Node.js 从零开发 web server博客项目[接口] Node.js 从零开发 web se ...
- Node.js 从零开发 web server博客项目[数据存储]
web server博客项目 Node.js 从零开发 web server博客项目[项目介绍] Node.js 从零开发 web server博客项目[接口] Node.js 从零开发 web se ...
- Node.js 从零开发 web server博客项目[koa2重构博客项目]
web server博客项目 Node.js 从零开发 web server博客项目[项目介绍] Node.js 从零开发 web server博客项目[接口] Node.js 从零开发 web se ...
- Node.js 从零开发 web server博客项目[安全]
web server博客项目 Node.js 从零开发 web server博客项目[项目介绍] Node.js 从零开发 web server博客项目[接口] Node.js 从零开发 web se ...
- Node.js 从零开发 web server博客项目[日志]
web server博客项目 Node.js 从零开发 web server博客项目[项目介绍] Node.js 从零开发 web server博客项目[接口] Node.js 从零开发 web se ...
- Node.js 从零开发 web server博客项目[登录]
web server博客项目 Node.js 从零开发 web server博客项目[项目介绍] Node.js 从零开发 web server博客项目[接口] Node.js 从零开发 web se ...
- Node.js 从零开发 web server博客项目[接口]
web server博客项目 Node.js 从零开发 web server博客项目[项目介绍] Node.js 从零开发 web server博客项目[接口] Node.js 从零开发 web se ...
- Node.js 从零开发 web server博客项目[项目介绍]
web server博客项目 Node.js 从零开发 web server博客项目[项目介绍] Node.js 从零开发 web server博客项目[接口] Node.js 从零开发 web se ...
随机推荐
- Elasticsearch基础分布式架构
写在前面的话:读书破万卷,编码如有神-------------------------------------------------------------------- 参考内容: <Ela ...
- [Visual Studio] SOA服务框架搭建
1.服务框架搭建 2.服务模板创建 3.Nuget引用 4.客户端调用 任务点: 1.分析SOA 2.修改SOA架构名称以及关键字 3.使用Nuget添加引用 4.选择服务模板进行创建 5.尝试调用 ...
- Python学习笔记(三):随机生成函数方法
本文是在Python2下总结! Python中的random模块用于生成随机数,如果想生成随机数需要先导入random的模块然后才能使用其中的方法,下面简单介绍一下常用的结果函数方法: 1·.rand ...
- 【原】MySQL实用SQL积累
[文档简述] 本文档用来记录一些常用的SQL语句,以达到快速查询的目的. [常用SQL] 1.mysql数据库中获取某个表的所有字段名 select COLUMN_NAME from informat ...
- java并发基础(一)
最近在看<java并发编程实战>,希望自己有毅力把它读完. 线程本身有很多优势,比如可以发挥多处理器的强大能力.建模更加简单.简化异步事件的处理.使用户界面的相应更加灵敏,但是更多的需要程 ...
- flash从数据流判断图片格式防止xss攻击
前段时间测试人员报了一个flash的xss bug,经分析用了Loader.loadBytes且没做数据流格式校验的程序都会中招,自测方法只需一行代码: ExternalInterface.call( ...
- SyncthingTray -- Syncthing wrapper for Windows
SyncthingTray Syncthing wrapper for Windows. Includes a small interface to configure start on boot a ...
- oracle systemtap tracing
https://github.com/LucaCanali?tab=repositories https://github.com/LucaCanali/Linux_tracing_scripts/t ...
- Iptables 指南 1.1.19
Iptables 指南 1.1.19 Oskar Andreasson oan@frozentux.net Copyright © 2001-2003 by Oskar Andreasson 本文在符 ...
- Iterative (non-recursive) Quick Sort
An iterative way of writing quick sort: #include <iostream> #include <stack> #include &l ...