小编Tam*_*mpa的帖子

如何从Express中的http请求获取未解析的查询字符串

我可以使用下面的方法来获取查询字符串.

  var query_string = request.query;
Run Code Online (Sandbox Code Playgroud)

我需要的是原始未解析的查询字符串.我怎么做到的?对于下面的url,查询字符串是{ tt: 'gg' },我需要tt=gg&hh=jj等....

http://127.0.0.1:8065?tt=gg

Server running at http://127.0.0.1:8065
{ tt: 'gg' }
Run Code Online (Sandbox Code Playgroud)

node.js express

19
推荐指数
2
解决办法
2万
查看次数

Zookeeper - 三个节点,只有错误

我有三个zookeeper节点.所有港口都是开放的.IP地址是正确的.下面是我的配置文件.由chef引导的所有节点都具有相同的安装和配置文件.

# The number of milliseconds of each tick
tickTime=3000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
dataDir=/var/lib/zookeeper
# Place the dataLogDir to a separate physical disc for better performance
# dataLogDir=/disk2/zookeeper

# the port at which the clients will connect
clientPort=2181

server.1=111.111.111:2888:3888
server.2=111.111.112:2888:3888
server.3=111.111.113:2888:3888
Run Code Online (Sandbox Code Playgroud)

这是其中一个节点的错误.所以...我对如何得到错误感到困惑,因为配置相当香草.所有三个节点都在做同样的事情.

2012-07-16 …
Run Code Online (Sandbox Code Playgroud)

apache-zookeeper

19
推荐指数
2
解决办法
3万
查看次数

angular-cli for angular2如何加载环境变量

我是angular-cli的新手,想要通过env为我的api服务调用加载url.例如

local: http://127.0.0.1:5000
dev: http://123.123.123.123:80
prod: https://123.123.123.123:443
Run Code Online (Sandbox Code Playgroud)

例如在environment.prod.ts中

我假设这个:

export const environment = {
  production: true
  "API_URL": "prod: https://123.123.123.123:443"
};
Run Code Online (Sandbox Code Playgroud)

但是从angular2,我如何调用以便获得API_URL?

例如

this.http.post(API_URL + '/auth', body, { headers: contentHeaders })
      .subscribe(
        response => {
          console.log(response.json().access_token);
          localStorage.setItem('id_token', response.json().access_token);
          this.router.navigate(['/dashboard']);
        },
        error => {
          alert(error.text());
          console.log(error.text());
        }
      );
  } 
Run Code Online (Sandbox Code Playgroud)

谢谢

angular2-cli angular

19
推荐指数
2
解决办法
2万
查看次数

我没有rxjs 6与角度6与间隔,switchMap和地图

我想将我的rxjs代码更新为6得到我没有得到它.

在我每隔5秒钟进行下面的新数据调查之前:

import { Observable, interval } from 'rxjs';
import { switchMap, map } from 'rxjs/operators';

var result = interval(5000).switchMap(() => this._authHttp.get(url)).map(res => res.json().results);
Run Code Online (Sandbox Code Playgroud)

现在......当然,它已经坏了,文档让我无处可去.

如何编写以上内容以符合rxjs 6?

谢谢

rxjs angular rxjs6

19
推荐指数
2
解决办法
3万
查看次数

Python Pandas - 如何在多索引上进行分组

以下是我的数据框.我做了一些转换来创建类别列并删除它派生自的原始列.现在我需要进行分组删除重复,例如Love,Fashion可以通过groupby总和汇总.

df.colunms = array([category, clicks, revenue, date, impressions, size], dtype=object)
df.values=
[[Love 0 0.36823 2013-11-04 380 300x250]
 [Love 183 474.81522 2013-11-04 374242 300x250]
 [Fashion 0 0.19434 2013-11-04 197 300x250]
 [Fashion 9 18.26422 2013-11-04 13363 300x250]]
Run Code Online (Sandbox Code Playgroud)

这是我创建数据帧时创建的索引

print df.index
array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
       17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
       34, …
Run Code Online (Sandbox Code Playgroud)

python multi-index dataframe pandas pandas-groupby

18
推荐指数
2
解决办法
3万
查看次数

Node.js和express - 如何读取cookie但未定义

我使用下面的方法使用express设置cookie.

res.cookie('test', 'yes', { 
    expires: new Date(Date.now() + 365*2*24*60*60*1000), 
    httpOnly: true 
});
Run Code Online (Sandbox Code Playgroud)

我正在使用中间件来尝试读取cookie:

app.use(express.cookieParser());

var cookie_id = req.cookies.test;
Run Code Online (Sandbox Code Playgroud)

问题是cookie_id是未定义的,因为它是'是'

Express server listening on port 8060 in development mode
TypeError: Cannot read property 'test' of undefined
    at /home/ubuntu/workspace/rtbopsConfig/rtbServers/rtbNodejsServer/nodeServer/app.js:48:29
    at callbacks (/home/ubuntu/workspace/rtbopsConfig/rtbServers/rtbNodejsServer/nodeServer/node_modules/express/lib/router/index.js:272:11)
    at param (/home/ubuntu/workspace/rtbopsConfig/rtbServers/rtbNodejsServer/nodeServer/node_modules/express/lib/router/index.js:246:11)
    at pass (/home/ubuntu/workspace/rtbopsConfig/rtbServers/rtbNodejsServer/nodeServer/node_modules/express/lib/router/index.js:253:5)
    at Router._dispatch (/home/ubuntu/workspace/rtbopsConfig/rtbServers/rtbNodejsServer/nodeServer/node_modules/express/lib/router/index.js:280:4)
    at Object.handle (/home/ubuntu/workspace/rtbopsConfig/rtbServers/rtbNodejsServer/nodeServer/node_modules/express/lib/router/index.js:45:10)
    at next (/home/ubuntu/workspace/rtbopsConfig/rtbServers/rtbNodejsServer/nodeServer/node_modules/express/node_modules/connect/lib/http.js:204:15)
    at Object.methodOverride [as handle] (/home/ubuntu/workspace/rtbopsConfig/rtbServers/rtbNodejsServer/nodeServer/node_modules/express/node_modules/connect/lib/middleware/methodOverride.js:35:5)
    at next (/home/ubuntu/workspace/rtbopsConfig/rtbServers/rtbNodejsServer/nodeServer/node_modules/express/node_modules/connect/lib/http.js:204:15)
    at Object.bodyParser [as handle] (/home/ubuntu/workspace/rtbopsConfig/rtbServers/rtbNodejsServer/nodeServer/node_modules/express/node_modules/connect/lib/middleware/bodyParser.js:88:61)
Run Code Online (Sandbox Code Playgroud)

我做错了什么?

Accept  text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding gzip, deflate
Accept-Language en-us,en;q=0.5
Connection  keep-alive
Cookie  test=yes …
Run Code Online (Sandbox Code Playgroud)

node.js express

17
推荐指数
2
解决办法
3万
查看次数

模板中的angular2和formControlName值

哦angular2 ......为什么这么难?

<input type="text" formControlName="exposure" type="hidden">
<label>{{exposure}}</label>
Run Code Online (Sandbox Code Playgroud)

如果我在输入中使用formControlName,则值是正确的.

如何获取模板中的曝光值?它在标签上是空白的

angular2-template angular

17
推荐指数
2
解决办法
2万
查看次数

Python - 列表和字典键之间的交集

我有一个如下所示的列表:

l1 = ['200:200', '90:728']
Run Code Online (Sandbox Code Playgroud)

我有一个字典,看起来像这样:

d1 = {'200:200':{'foo':'bar'},'300:300':{'foo':'bar'}}
Run Code Online (Sandbox Code Playgroud)

我需要过滤掉只有键在l1中的词典.字典应如下所示:

result = {'200:200':{'foo':'bar'}}
Run Code Online (Sandbox Code Playgroud)

本质上是一个列表和一个字典的键的交集,同时返回字典的子部分.

如果时间是大型设备的问题,我该如何有效地做到这一点?

谢谢

python

16
推荐指数
3
解决办法
7848
查看次数

Python Fabric - 找不到主机.请指定(单个)主机字符串以进行连接:

我如何获得没有找到主机.请指定(单个)主机字符串进行连接:

如何解决面料问题?

def bootstrap():
    host = 'ec2-54-xxx.xxx.xxx.compute-1.amazonaws.com'
    env.hosts = [host]
    env.user = "ubuntu"
    env.key_filename = "/home/ubuntu/omg.pem"

> command run
>> fab bootstrap
> No hosts found. Please specify (single) host string for connection: 
Run Code Online (Sandbox Code Playgroud)

python fabric

16
推荐指数
2
解决办法
2万
查看次数

logstash - 线程">输出"中的异常org.elasticsearch.discovery.MasterNotDiscoveredException:等待[30s]

日志存储对我来说是100%的灾难.我在同一台机器上使用LS 1.4.1和ES 1.02.

以下是我启动logstash索引器的方法:

/usr/local/share/logstash-1.4.1/bin/logstash -f /usr/local/share/logstash.indexer.config
input {
  redis {
    host => "redis.queue.do.development.sf.test.com"
    data_type => "list"
    key => "logstash"
    codec => json
  }
}

output {
        stdout { }
        elasticsearch {
                bind_host => "127.0.0.1"
                port => "9300"
        }
}
Run Code Online (Sandbox Code Playgroud)

ES我设置:

network.bind_host: 127.0.0.1
discovery.zen.ping.multicast.enabled: false
discovery.zen.ping.unicast.hosts: ["127.0.0.1:9300"]
Run Code Online (Sandbox Code Playgroud)

哇..这就是我得到的:

/usr/local/share/logstash-1.4.1/bin/logstash -f /usr/local/share/logstash.indexer.config
Using milestone 2 input plugin 'redis'. This plugin should be stable, but if you see strange behavior, please let us know! For more information on plugin milestones, see http://logstash.net/docs/1.4.1/plugin-milestones …
Run Code Online (Sandbox Code Playgroud)

elasticsearch logstash

15
推荐指数
2
解决办法
2万
查看次数