问题
当使用Safari作为浏览器而不是Chrome浏览器时,加载Web应用程序首页时会收到401状态,这仅在该选项卡上首次出现,当我们打开新的选项卡并重新加载应用程序时,它加载正常。
我们使用的技术是MEAN堆栈,当我们使用Chrome / Firefox作为浏览器时,一切都很好(没有401错误,并且身份验证似乎很好),但是当我们切换到Safari时,它不起作用。
我在React on SO上看到了类似的文章Safari接收401状态而不是Chrome,并确保端点具有正斜杠
API调用
get_change_lifecycle_data(){
const params = new HttpParams().set('params', this.enteredValue);
this.http.get('https://change-life-cycle.region02.hoster.company.com/api/change_life_cycle/',{params})
.subscribe(response => {
console.log("change data:");
console.log(response);
this.newPost = response
// this.splice_gerrits();
});
}
Run Code Online (Sandbox Code Playgroud)
失败的请求:
Summary
URL: https://bati.company.com/runtime-es2015.858f8dd898b75fe86926.js
Status: 401 Unauthorized
Source: Network
Request
Origin: https://bati.company.com
Accept: */*
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) companyWebKit/605.1.15 (KHTML, like Gecko) Version/11.1.2 Safari/605.1.15
Referer: https://bati.company.com/
Response
Content-Type: text/html
Date: Tue, 20 Aug 2019 00:02:58 GMT
Connection: keep-alive
Server: companyHttpServer/54b48526
Content-Length: 207
X-B3-TraceId: …Run Code Online (Sandbox Code Playgroud) 我有一个 python 客户端从带有 node.js API 的服务器监听 SSE 事件
流程是我通过向 node.js API 发送一个事件call_notification.py并seevents.py使用循环运行run.sh(见下文)
但是我没有看到 python 客户端正在接收这个 SSE 事件?关于为什么会这样的任何指导?
call_notification.py
import requests
input_json = {'BATS':'678910','root_version':'12A12'}
url = 'http://company.com/api/root_event_notification?params=%s'%input_json
response = requests.get(url)
print response.text
Run Code Online (Sandbox Code Playgroud)
节点.js API
app.get("/api/root_event_notification", (req, res, next) => {
console.log(req.query.params)
var events = require('events');
var eventEmitter = new events.EventEmitter();
//Create an event handler:
var myEventHandler = function () {
console.log('new_root_announced!');
res.status(200).json({
message: "New root build released!",
posts: req.query.params
});
}
Run Code Online (Sandbox Code Playgroud)
seeevents.py(python 客户端监听 SSE 事件) …
我有两个字典,我想将这两个字符串组合在格式键的列表中 - >值,键 - >值...删除任何无或['']
目前我有以下我可以结合dicts但不创建组合列表...我有expecte输出..任何输入appreeciated
dict1={'313115': ['313113'], '311957': None}
dict2={'253036': [''], '305403': [], '12345': ['']}
dict = dict(dict1.items() + dict2.items())
print dict
{'313115': ['313113'], '311957': None, '253036': [''], '12345': [''], '305403': []}
EXPECTED OUTPUT:
['313115','313113','311957','253036','305403','12345']
Run Code Online (Sandbox Code Playgroud) 我正尝试将None关键字作为命令行参数传递给脚本,如下所示,如果我明确提到Category=None它可以工作,但切换到sys.argv[1]它的那一刻失败,那么如何解决此问题的任何指针?
category = None --> works
#category=sys.argv[1] --> doesn't work
Run Code Online (Sandbox Code Playgroud)
所以我尝试如下仍然无法正常工作
if sys.argv[1].strip()==None:
category = None
else:
category=sys.argv[1].strip()
Run Code Online (Sandbox Code Playgroud)
命令行通过:
script.py None
Run Code Online (Sandbox Code Playgroud) 每当我尝试运行如下脚本时,我都会得到以下结果.代码有什么问题?
1.python test.py
不打印用法.
2.python test.py http://link.com/index.php?title=tesst&action=raw
打印:
"'action' is not recognized as an internal or external command,
operable program or batch file."
我的剧本:
# Version YYYYMMDD
version = "20121112"
# File type to be output to logs
# Should be changed to exe before building the exe.
fileType = "py"
# Import sys to read command line arguments
import sys, getopt
#import pdb
#pdb.set_trace()
import argparse
def update (url):
req = urllib2.Request(url=url)
try:
f = urllib2.urlopen(req)
txt …Run Code Online (Sandbox Code Playgroud) I have a list as follows,how to delete the junk '\x00\x00.. in front of 563015
['\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00563015', '553261', '541526']
Run Code Online (Sandbox Code Playgroud) 我的日期看起来像“2012-11-02 21:00:20.000397”,下面的代码遇到了以下错误……谁能提供有关错误的输入?
代码:-
create_date = datetime.strptime(str(CRItem['CR Created Date']), '%Y-%m-%d %H:%M:%S')
CR_created_date = "{}/{}/{}".format(create_date.month,d.day,d.year)
CRMailBody = CRMailBody + "<tr>"
Run Code Online (Sandbox Code Playgroud)
错误:-
Traceback (most recent call last):
File "test.py", line 482, in <module>
create_date = datetime.strptime(str(CRItem['CR Created Date']), '%Y-%m-%d %H:%M:%S')
File "C:\Python27\lib\_strptime.py", line 328, in _strptime
data_string[found.end():])
ValueError: unconverted data remains: .000397
Run Code Online (Sandbox Code Playgroud) 我正在使用下面的代码遇到以下错误,基本上下面是我想要做的,如何在不改变原始目标的情况下修改我的代码...
如果任何值是带有值的键,则对于每个值(这是键)递归检查其值,直到没有并删除重复的行...示例输入和输出如下所示:
KEY VALUES
353311
344670
332807 353314
338169 334478
334478 123456 34567
123456 98670
34567 11111
353314 353311
348521 350166 350168 350169 350170
350166 348521
350168 348521
350169 348521
350170 348521
EXPECTED OUTPUT
344670
332807 353314 353311
338169 334478 123456 34567 98670 11111
348521 350166 350168 350169 350170
Run Code Online (Sandbox Code Playgroud)
码:-
from collections import OrderedDict
def main ():
with open('gerrit_dependencylist.txt') as f:
dic = OrderedDict()
seen = set()
for line in f:
#print dic,line
spl = line.split()
#print "SPL"
#print …Run Code Online (Sandbox Code Playgroud)