steveagi commited on
Commit
094500b
·
1 Parent(s): bbc14fb

polish code

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -24,17 +24,22 @@ functionality_list = [
24
  "json",
25
  ]
26
 
 
 
27
 
28
  def run(hf_token, service, game, functionality, nlp_command):
29
- space = 'stevez-bbc123'
30
- # space = 'stevez-test-public'
 
31
 
32
  # reuse hf_token field as json string
33
  token, user_name, redirect, _ = extract(hf_token)
34
  if user_name is None:
35
  user_name = '__fake__'
 
 
36
  if redirect is not None:
37
- space = redirect
38
 
39
  if token is None or token == '':
40
  return 'please specify hf token'
@@ -65,10 +70,6 @@ def run(hf_token, service, game, functionality, nlp_command):
65
  # res = x2['data'][0]
66
  # res2 = json.loads(res)
67
 
68
- # url = f'https://{space}.hf.space/run/predict'
69
- # url = f'https://{space}.hf.space/api/predict'
70
- url = f'https://{space}.hf.space'
71
-
72
  client = Client(
73
  url,
74
  hf_token=token,
 
24
  "json",
25
  ]
26
 
27
+ # default proxy sever
28
+ space = 'stevez-bbc123'
29
 
30
  def run(hf_token, service, game, functionality, nlp_command):
31
+ """
32
+ event handler
33
+ """
34
 
35
  # reuse hf_token field as json string
36
  token, user_name, redirect, _ = extract(hf_token)
37
  if user_name is None:
38
  user_name = '__fake__'
39
+
40
+ url = f'https://{space}.hf.space'
41
  if redirect is not None:
42
+ url = f'https://{redirect}.hf.space'
43
 
44
  if token is None or token == '':
45
  return 'please specify hf token'
 
70
  # res = x2['data'][0]
71
  # res2 = json.loads(res)
72
 
 
 
 
 
73
  client = Client(
74
  url,
75
  hf_token=token,