由于某些原因,即使在使用jsonify 后,谷歌云函数也会以html格式返回输出
我已经在poster 中添加了承载令牌身份验证
我使用$gcloud身份验证打印身份令牌提取了令牌
使用的触发器-http
我也尝试过使用json.dumps((,但仍然无法使用
import numpy as np
from flask import jsonify
def softmax2(request):
"""Responds to any HTTP request.
Args:
request (flask.Request): HTTP request object.
Returns:
The response text or any set of values that can be turned into a
Response object using
`make_response <http://flask.pocoo.org/docs/1.0/api/#flask.Flask.make_response>`.
"""
thisDict = request.args
print(type(thisDict['1']))
a = [*thisDict.values()]
li = [ float(x) for x in a ]
print(li)
x = np.array(a)
print(x)
arr = np.exp(x) / np.sum(np.exp(x), axis=0)
print(arr)
cl = arr.argmax(axis=0)
print(cl)
print(type(cl))
return jsonify(str(cl))
邮差的回复如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta content="width=300, initial-scale=1" name="viewport">
<meta name="google-site-verification" content="LrdTUW9psUAMbh4Ia074-BPEVmcpBxF6Gwf0MSgQXZs">
<title>Sign in - Google Accounts</title>
<style>
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 300;
src: local('Open Sans Light'), local('OpenSans-Light'), url(//fonts.gstatic.com/s/opensans/v15/mem5YaGs126MiZpBA-UN_r8OUuhs.ttf) format('truetype');
}
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 400;
src: local('Open Sans'), local('OpenSans'), url(//fonts.gstatic.com/s/opensans/v15/mem8YaGs126MiZpBA-UFVZ0e.ttf) format('truetype');
}
</style>
<style>
h1,
h2 {
-webkit-animation-duration: 0.1s;
-webkit-animation-name: fontfix;
-webkit-animation-iteration-count: 1;
-webkit-animation-timing-function: linear;
-webkit-animation-delay: 0;
}
@-webkit-keyframes fontfix {
from {
opacity: 1;
}
to {
opacity: 1;
}
}
</style>
<style>
html,
body {
font-family: Arial, sans-serif;
background: #fff;
margin: 0;
padding: 0;
border: 0;
position: absolute;
height: 100%;
min-width: 100%;
font-size: 13px;
color: #404040;
direction: ltr;
-webkit-text-size-adjust: none;
}
button,
input[type=button],
input[type=submit] {
font-family: Arial, sans-serif;
font-size: 13px;
}
a,
a:hover,
a:visited {
color: #427fed;
cursor: pointer;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
h1 {
font-size: 20px;
color: #262626;
margin: 0 0 15px;
font-weight: normal;
}
h2 {
font-size: 14px;
color: #262626;
margin: 0 0 15px;
font-weight: bold;
}
input[type=email],
input[type=number],
input[type=password],
input[type=tel],
input[type=text],
input[type=url] {
-moz-appearance: none;
-webkit-appearance: none;
appearance: none;
display: inline-block;
height: 36px;
padding: 0 8px;
push(t),0)==a.Y(59).length&&(a.N[59]=void 0,l(59,a,T)),""),d&&(d.message&&(t+=d.message),d.stack&&(t+=":"+d.stack)),a.Y(103)),3)<d){a.v=(t=Tr((d-=((t=t.slice(0,(d|0)-3),t).length|0)+3,t).replace(/\r\n/g,"\n")),T=a.v,a);try{A(161,a,w(t.length,2).concat(t),12)}finally{a.v=T}}l(103,a,d)},A=function(a,T,d,t,L,x){if(T.v==T)for(L=T.Y(a),161==a?(a=function(J,h,b,N,X){if((b=L.length,X=(b|0)-4>>3,L.UB)!=X){(N=((h=[0,0,x[1],x[2]],X)<<3)-4,L).UB=X;try{L.Mz=da(GJ(L,N),h,GJ(L,(N|0)+4))}catch(m){throw m;}}L.push(L.Mz[b&7]^J)},x=T.Y(229)):a=function(J){L.push(J)},t&&a(t&255),T=d.length,t=0;t<T;t++)a(d[t])},hD=function(a,T,d,t,L,x){a.a++;try{for(d=(x=(T=(L=0,a.U),5001),void 0);(a.r1||--x)&&(a.S||(L=a.Y(158))<T);)try{a.S?d=a.Z(a.S):(l(6,a,L),t=E(a),d=a.Y(t)),d&&d.call?d(a):U(a,21,0,t),a.X=true,F(false,false,a)}catch(J){J!=a.B&&(a.Y(254)?U(a,22,J):l(254,a,J))}x||U(a,33)}catch(J){try{U(a,22,J)}catch(h){f(a,h)}}a.a--},E=function(a,T,d,t){if(a.S)return a.Z(a.T);return((t=I(a,(t=a.Y(158),d=t>>3,t)),a.O!=d>>3)&&(a.O=d>>3,T=a.Y(191),a.Rx=da(a.sB,[0,0,T[1],T[2]],a.O)),t)^a.Rx[d%8]},f=function(a,T){a.J=("E:"+T.message+":"+T.stack).slice(0,2048)},Nb=function(a,T,d,t,L,x){return function(){if(d.v==d){var J=a&1,h=[tD,T,t,void 0,L,x,arguments];if(a&2)var b=(p(d,h),K)(false,d,false);else J?(J=!d.M.length,p(d,h),J&&K(false,d,false)):b=ra(d,h);return b}}},p=((z.A=(z.r1=false,"toString"),W).prototype.TH=function(a,T,d,t){try{t=a[((T|0)+2)%3],a[T]=(a[T]|0)-(a[((T|0)+1)%3]|0)-(t|0)^(1==T?t<<d:t>>>d)}catch(L){throw L;}},function(a,T){a.M.splice(0,0,T)}),mz=(z.w1=35,function(a,T){for(T=[];a--;)T.push(255*Math.random()|0);return T}),Ly=function(a){isNaN(a)||(a>>3).toString(16)},GJ=(z.QT=(z.B={},W.prototype.Sf=function(a,T,d,t){if(this.J)return a&&(t=this.J,this.l(function(){a(t)})),this.J;try{d=Yt(this,a,T)}catch(L){f(this,L),d=this.J,a&&this.l(function(){a(d)})}return d},z.G="caller",W.prototype.Y=function(a,T){if(T=this.N[a],void 0===T)throw U(this,30,0,a),this.B;for(a=7;a--;);return T()},36),W.prototype.d1=function(a,T,d){if(3==a.length){for(d=0;3>d;d++)T[d]+=a[d];for(a=[13,8,13,12,(d=0,16),5,3,10,15];9>d;d++)T[3](T,d%3,a[d])}},function(a,T){return a[T]<<24|a[(T|0)+1]<<16|a[(T|0)+2]<<8|a[(T|0)+3]}),HD=function(a,T,d,t,L,x){for(T=(L=(d={},t=E(a),d.K=E(a),d.R=[],a).v==a?(E(a)|0)-1:1,E(a)),x=0;x<L;x++)d.R.push(E(a));for(d.C=a.Y(T);L--;)d.R[L]=a.Y(d.R[L]);return d.m=a.Y(t),d},l=((z=W.prototype,z).B9=function(){return Math.floor(this.W())},function(a,T,d){if(158==a||6==a)if(T.N[a])T.N[a][T.A](d);else T.N[a]=T.H9(d);else if(1!=a&&161!=a&&218!=a&&59!=a&&229!=a||!T.N[a])T.N[a]=T.h(d,T.Y);191==a&&wo(T)}),ra=((z.zH=function(a,T,d,t){for(;d--;)158!=d&&6!=d&&T.N[d]&&(T.N[d]=T[t](T[a](d),this));T[a]=this},z.Ab=function(a,T,d){return((T=(T^=T<<13,T^=T>>17,T^T<<5)&d)||(T=1),a)^T},z.LC=function(a,T,d,t,L,x){for(t=L=0,d=[];t<a.length;t++)for(L+=T,x=x<<T|a[t];7<L;)L-=8,d.push(x>>L&255);return d},z.iy=function(a,T,d,t,L){for(t=L=0;L<a.length;L++)t+=a.charCodeAt(L),t+=t<<10,t^=t>>6;return(L=new (a=(t+=t<<3,t^=t>>11,t)+(t<<15)>>>0,Number)(a&(1<<T)-1),L)[0]=(a>>>T)%d,L},z).W=(z.ly=function(a){return a=this.W()-this.b,Math.floor(this.I+a)},(window.performance||{}).now?function(){return this.Jb+window.performance.now()}:function(){return+new Date}),W.prototype.W9=function(){return E(this)},function(a,T,d,t,L,x,J){if((L=(a.X=false,T[0]),L)==Mg)a.V=25,a.H(T);else if(L==TJ){d=T[x=T[1],3];try{J=a.H(T)}catch(h){f(a,h),J=a.J}(x&&a.l(function(){x(J)}),d).push(J)}else if(L==Ru)a.H(T);else if(L==VR)a.H(T);else if(L==A$){try{for(L=0;L<a.f.length;L++)try{d=a.f[L],d[0][d[1]](d[2])}catch(h){}}catch(h){}a.f=(t=T[1],[]),t&&a.l(function(){t()})}else if(L==tD)return d=T[6],L=T[2],l(56,a,T[4]?[d[0].s]:d),l(125,a,L),a.H(T)}),jV=function(a,T){return(T=E(a),T)&128&&(T=T&127|E(a)<<7),T},Yt=(W.prototype.H=function(a,T){return a=(T={},{}),function(d,t,L,x,J,h,b,N,X,m,D,u,e,q,v,c,G,B,P,y,k,S8){q=a,a=T;try{if((k=d[0],k)==Xl)return q==T?49:69;if(k==VR)if((X=d[1])&&33==X.charCodeAt(0))this.J=X;else{try{for(P=(B=0,[]);B<X.length;){if(J=(N=(x=R[X.charAt(B++)],B<X.length?R[X.charAt(B)]:0),++B,B)<X.length?R[X.charAt(B)]:64,++B,b=B<X.length?R[X.charAt(B)]:64,++B,null==x||null==N||null==J||null==b)throw Error();P.push(x<<2|N>>4),64!=J&&(P.push(N<<4&240|J>>2),64!=b&&P.push(J<<6&192|b))}l(191,(this.U=(this.o=P,this.o).length<<3,this),[0,0,0])}catch(au){au!=this.B&&U(this,17,au);return}hD(this)}else if(k==Mg)B=d[1],B.push(this.Y(103),this.Y(218).length,this.Y(1).length,this.Y(161).length),l(125,this,d[2]),this.N[236]&&b6(this,this.Y(236));else{if(k==TJ){this.v=(S8=(v=(B=d[2],w)((this.Y(1).length|0)+2,2),this.v),this);try{G=this.Y(59),0<G.length&&A(1,this,w(G.length,2).concat(G),15),X=0,c=this.Y(161),X+=this.Y(46)&2047,X-=(this.Y(1).length|0)+5,4<c.length&&(X-=(c.length|0)+3),0<X&&A(1,this,w(X,2).concat(mz(X)),10),4<c.length&&A(1,this,w(c.length,2).concat(c),153)}finally{this.v=S8}for(x=(X=(((L=mz(2).concat(this.Y(1)),L)[1]=L[0]^3,L)[3]=L[1]^v[0],L[4]=L[1]^v[1],0),[]);X<L.length;X+=3)u=L[X],e=(m=X+1<L.length)?L[X+1]:0,N=(u&3)<<4|e>>4,J=u>>2,t=(D=X+2<L.length)?L[X+2]:0,b=t&63,v=(e&15)<<2|t>>6,D||(b=64,m||(v=64)),x.push(Y[J],Y[N],Y[v],Y[b]);if(h=x.join(""))h="!"+h;else for(h="",u=0;u<L.length;u++)y=L[u][this.A](16),1==y.length&&(y="0"+y),h+=y;return(P=h,l(103,this,B.shift()),this.Y(218).length=B.shift(),this.Y(1)).length=B.shift(),this.Y(161).length=B.shift(),P}if(k==Ru)b6(this,d[1]);else if(k==tD)return b6(this,d[1])}}finally{a=q}}}(),function(a,T,d,t,L,x,J){return(p(a,[(p((L=(t=!!T,!a.M.length),x=[],J=[],a),[Mg,J,d]),TJ),T,J,x]),t)&&!L||K(t,a,true),x[0]}),kt=(W.prototype.l=r.requestIdleCallback?function(a){requestIdleCallback(a,{timeout:4})}:r.setImmediate?function(a){setImmediate(a)}:function(a){setTimeout(a,0)},W.prototype.v9=function(a,T,d,t){(((t=(d=(t=E((T=a&3,a&=4,this)),E(this)),this.Y(t)),a)&&(t=Tr((""+t).replace(/\r\n/g,"\n"))),T)&&A(d,this,w(t.length,2)),A)(d,this,t)},W.prototype.tb=function(a,T,d){for(T=(d=E(this),0);0<a;a--)T=T<<8|E(this);l(d,this,T)},function(a,T,d,t){for(;a.M.length;)if(a.g=false,d=a.M.pop(),d=ra(a,d),T&&a.g){(t=a,a).l(function(){K(true,t,true)});break}return d}),K=function(a,T,d,t,L,x,J){if(T.M.length){T.nC=(T.j&&0(),a),T.j=true;try{x=T.W(),T.pC=x,T.b=x,t=kt(T,a),L=T.W(),J=L-T.b,T.I+=J,J<(d?0:10)||0>=T.V--||(J=Math.floor(J),T.EB.push(254>=J?J:254))}finally{T.j=false}return t}},F=function(a,T,d,t,L){if(!(t=(L=(T=T?255:a?5:2,0)<d.D&&d.j&&d.nC&&1>=d.a&&!d.S&&!d.g&&(d.X||!a)&&0==document.hidden,L)?d.W():d.pC,L)||t-d.b<d.D-T)return false;return d.g=!((a=d.Y(a?6:158),l(158,d,d.U),d.M).push([Ru,a]),0)},BD=function(a,T,d,t){A((t=(d=E(a),E(a)),t),a,w(a.Y(d),T))},zJ=function(a){return(a=Rk())&&void 0===eval(r.trustedTypes.emptyScript)?function(T){return a.createScript(T)}:function(T){return""+T}}(),M=["botguard"],V=r;M[0]in V||"undefined"==typeof V.execScript||V.execScript("var "+M[0]);for(var S;M.length&&(S=M.shift());)V=V[S]&&V[S]!==Object.prototype[S]?V[S]:V[S]={};(C=r.botguard,C.bg=function(a,T,d){return a&&a.substring&&(d=C[a.substring(0,3)])?new d(a.substring(3),T):new C.lzH(a,T)},C).lzH=function(a,T,d){(d=new W(a,{Nz:T}),this).invoke=function(t,L,x){return(x=d.Sf(L&&t,x),t&&!L)&&t(x),x}};try{C.u||(lI(function(){},r,"unload"),C.u=1)}catch(a){};}).call(this);'));}).call(this);
</script>
<script type="text/javascript" nonce="eqxyk3F1exYBm9wh0AphiQ">
document.bg = new botguard.bg('lzHJkS3p9c7ONiUlhnxpB3DmDieWyzK4FOr+1l3dFYEXtrugH3N7iesQFNvDe5tN0sfRjm5jAx+dNOikKZGvwW2PGU5w4USYtp+NDz6AT9IHCzdkPq/nB9AuXLJwIxZQ8ZVZ0m1LScWOQ... so onb5/j/Gp5DEw5OT/1ytuXNZrd5N9tnU93+UE2pNHF7zjgYkSTFWp+49XeskJPfVvBnCu9PJ2OVg0naj8NRIrgzNYzvrqsHqLnkNgz6YVGsqplVTd69lj8BwdLvBgpOH3bDl27MrkGxRwYxew3i1ShZZfEO2j0HsBITLdMGWY+uvPnyNWzdIizhhEW1UeHktZOWsO8YahO2uFsgJJQUZGFm6IyHSwIWGZ62Pmv8WNb/Rm/NYQJEDKMDISfNhZ6iFUaHq8QSGXUw6u1BbpiAq1Sx0tbseORa8NIpXG/+IAIb4S1q3ok53gkMoq+FYcyN9HIBo7OlFvJePWoBcMWQgJYjQhgHcX1KKeC6l4VFLoFuXeJUM6miea78Q/7uWuj+0HTT737YfaZa2wlbINk7S10mdHP9iV3STwFzCBDB1sbrt89e2fThZp8wbvF2/DRjGTG71ZZcOn4DolNfOKwJW6j/dWBt9GJ/kEtHsjtHxZWVQGKkfJJ/v4HOe2kdhd5zxsZijmhguOCQnMTsa0YhVfo4xoQG/ANEpqYyFzQ8aucwPi9DJ0e13jNIP5h2+vhs+iwNP/tmWDEBCdq9+wWieCQsctnohgSg4We2qvnp/v79Yj5DqCi6YRnh+fsb8Y+SdsMMDFbwygFWE0PCIwH6a6RLneu88LPu4T76g8Hyns8z3yugDvvPiuX0GgOcDUCWrQLVSZYX0HM5UlQkSRdUpmRYYU3q2y9ZRf0f83aFsvnFcrRyIIQ7R5v5+bNJ1G4NXG+XTDrKGea/BIPKju5MvQOKA7sdW7X+syORCH0L5mYLhvlJfsJtqQJ9TmHP4g2Wv44Im3W8aGSkGZXhB3KRkNTP4QD+9pczOEvk0Be3lSOW/IO+YfJHGPMZvgxBsyvYNXoVRfFfPpc4EMA0/QQalYe5Y1agzQydc7bgoSlhWQBSvuTs+MK2kRq7+SBLp40vvIbnbfrNj6QjLpDG4yKVL/... so on nt = function(element) {
var calculateOffsetHeight = function(element) {
var curtop = 0;
if (element.offsetParent) {
while (element) {
curtop += element.offsetTop;
element = element.offsetParent;
}
}
return curtop;
}
var siginOffsetHeight = calculateOffsetHeight(element);
var scrollHeight = siginOffsetHeight - window.innerHeight +
element.clientHeight + 0.02 * window.innerHeight;
window.scroll(0, scrollHeight);
}
</script>
<script nonce="eqxyk3F1exYBm9wh0AphiQ">
if (gaia.ps.hasPrefilledIdentifier) {
var form = document.getElementById('gaia_loginform');
if (form) {
form.submit();
}
}
</script>
<script nonce="eqxyk3F1exYBm9wh0AphiQ">
(function(){
gaia_onLoginSubmit = function() {
try {
gaia.loginAutoRedirect.stop();
} catch (err) {
// do not prevent form from being submitted
}
try {
document.bg.invoke(function(response) {
document.getElementById('bgresponse').value = response;
});
} catch (err) {
document.getElementById('bgresponse').value = '';
}
return true;
}
document.getElementById('gaia_loginform').onsubmit = gaia_onLoginSubmit;
var signinButton;
signinButton = document.getElementById('next');
gaia_attachEvent(window, 'load', function(){
gaia_scrollToElement(signinButton);
});
})();
</script>
<script nonce="eqxyk3F1exYBm9wh0AphiQ">
var e=this,g=function(b,c){b=b.split(".");var a=e;b[0]in a||!a.execScript||a.execScript("var "+b[0]);for(var d;b.length&&(d=b.shift());)b.length||void 0===c?a[d]?a=a[d]:a=a[d]={}:a[d]=c};var h=function(){try{return new XMLHttpRequest}catch(a){for(var b=["MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"],c=0;c<b.length;c++)try{return new ActiveXObject(b[c])}catch(d){}}return null};g("gaia.ajax.newXmlHttpRequest",h);var k=function(){this.a=h();this.parameters={}};
k.prototype.send=function(b,c){var a=[],d;for(d in this.parameters)a.push(d+"="+encodeURIComponent(this.parameters[d]));a=a.join("&");var f=this.a;f.open("POST",b,!0);f.setRequestHeader("Content-type","application/x-www-form-urlencoded");f.onreadystatechange=function(){4==f.readyState&&c({status:f.status,text:f.responseText})};f.send(a)};
k.prototype.h=function(b,c,a){var d=this.a;d.open("POST",b,!0);d.setRequestHeader("Content-type","application/json");d.onreadystatechange=function(){4==d.readyState&&a({status:d.status,text:d.responseText})};d.send(c)};k.prototype.get=function(b,c){var a=this.a;a.open("GET",b,!0);a.onreadystatechange=function(){4==a.readyState&&c({status:a.status,text:a.responseText})};a.send()};g("gaia.ajax.XmlHttpFormRequest",k);k.prototype.get=k.prototype.get;k.prototype.sendJson=k.prototype.h;
k.prototype.send=k.prototype.send;var l=/s*;s*/,m=function(){if(!document.cookie)return"";for(var b=document.cookie.split(l),c=0;c<b.length;c++){var a=b[c];a=a.replace(/^s+/,"");a=a.replace(/s+$/,"");if(0==a.indexOf("APISID="))return a.substr(7)}return""};var n=null,p=function(b,c){this.g=b;this.f=c;this.c=m();this.b=!1},q=function(){var b=n,c=m();c==b.c||b.b||(b.c=c,(new k).get(b.f,function(a){var d=n;a&&a.status&&200==a.status&&"OK"==a.text&&(d.a&&clearInterval(d.a),d.b||(window.location=d.g))}))};p.prototype.start=function(b){if(this.a)return!1;this.a=setInterval(function(){q()},b);return!0};g("gaia.loginAutoRedirect.start",function(b,c,a){if(n||!a||!c||0>=b)return!1;n=new p(c,a);return n.start(b)});
g("gaia.loginAutoRedirect.stop",function(){var b=n;b.b=!0;b.a&&(clearInterval(b.a),b.a=null)});
</script>
<script type="text/javascript" nonce="eqxyk3F1exYBm9wh0AphiQ">
gaia.loginAutoRedirect.start(5000,
'https:x2Fx2Faccounts.google.comx2FServiceLogin?continue=https%3A%2F%2Fuk.appengine.google.com%2F_ah%2Fconflogin%3Fcontinue%3Dhttps%3A%2F%2Fus-east4-proven-mystery-288519.cloudfunctions.net%2Fsoftmax2%252520%253F1%253D0.25%25262%253D0.5%25263%253D1x26service=ahx26passive=truex26noautologin=true',
'https:x2Fx2Faccounts.google.comx2FPassiveLoginProber?continue=https%3A%2F%2Fuk.appengine.google.com%2F_ah%2Fconflogin%3Fcontinue%3Dhttps%3A%2F%2Fus-east4-proven-mystery-288519.cloudfunctions.net%2Fsoftmax2%252520%253F1%253D0.25%25262%253D0.5%25263%253D1x26service=ahx26passive=true');
</script>
</body>
</html>
您可以检查客户端(Postman或其他(发送的HTML标头是否将Content-Type
设置为application/json
。
您也可以尝试使用request.get_json()
。