Spaces:
Build error
Build error
Merge pull request #8 from east-and-west-magic/feature-enable-source
Browse filesFiles changed (2)
- app.py+5-3
- extract.py+13-7
44 unmodified lines4546474849505138 unmodified lines9091929394959617 unmodified lines1141151161171181199 unmodified lines12913013113213313413544 unmodified lines"""# reuse hf_token field as json stringtoken, user_name, redirect, _ = extract(hf_token)if user_name is None:user_name = "__fake__"38 unmodified lineselse:try:assert "games" in service_listif service == "games":print(f"{beijing()} [{user_name}] [{game}] {nlp_command}")client = Client(url,17 unmodified linesoutp["proxy-version"] = proxy_versionoutp["user"] = user_nameoutp["game"] = gamecalling_start = beijing()print(f"calling logger starts at {beijing()}")app_util.call_logger(outp, identity, token)9 unmodified linestimecost = service_end.timestamp() - service_start.timestamp()print(f">>>>>>>>>>>>>>> service ends at {service_end}, "+ f"costs {timecost:.2f}s <<<<<<<<<<<<<<<")return json.dumps(outp, indent=4)44 unmodified lines4546474849505138 unmodified lines9091929394959617 unmodified lines1141151161171181191201219 unmodified lines13113213313413513613744 unmodified lines"""# reuse hf_token field as json stringtoken, user_name, redirect, source, _ = extract(hf_token)if user_name is None:user_name = "__fake__"38 unmodified lineselse:try:assert "games" in service_listif service == "games":print(f"{beijing()} [{user_name}] [{game}] {nlp_command}")client = Client(url,17 unmodified linesoutp["proxy-version"] = proxy_versionoutp["user"] = user_nameoutp["game"] = gameif source:outp["source"] = sourcecalling_start = beijing()print(f"calling logger starts at {beijing()}")app_util.call_logger(outp, identity, token)9 unmodified linestimecost = service_end.timestamp() - service_start.timestamp()print(f">>>>>>>>>>>>>>> service ends at {service_end}, "+ f"costs {timecost:.2f}s <<<<<<<<<<<<<<<\n")return json.dumps(outp, indent=4)
1234567891011121314151617181920212223242526272829import jsondef extract(hf_token):"""Extract token, user, redirect, and info from input hf_token.If hf_token is simple, it is the token itself."""info = {} # a copy of hf_token in json formattry:info = json.loads(hf_token)except json.decoder.JSONDecodeError:return hf_token, None, None, Nonetry:token = info['token']except KeyError:token = Nonetry:user = info['user']except KeyError:user = Nonetry:redirect = info['redirect']except KeyError:redirect = Nonereturn token, user, redirect, info1234567891011121314151617181920212223242526272829303132333435import jsondef extract(hf_token):"""Extract token, user, redirect, source, and info from input hf_token.If hf_token is simple, it is the token itself."""info = {} # a copy of hf_token in json formattry:info = json.loads(hf_token)except json.decoder.JSONDecodeError:return hf_token, None, None, None, Nonetry:token = info["token"]except KeyError:token = Nonetry:user = info["user"]except KeyError:user = Nonetry:redirect = info["redirect"]except KeyError:redirect = Nonetry:source = info["source"]except KeyError:source = Nonereturn token, user, redirect, source, info
app.py+5-3
extract.py+13-7