baxin commited on
Commit
d1f247f
1 Parent(s): 7962d98

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import gradio as gr
2
  import requests
3
  import uuid
 
4
 
5
  def generate_unique_name():
6
  unique_name = str(uuid.uuid4()) + ".py"
@@ -8,9 +9,10 @@ def generate_unique_name():
8
 
9
  def send_post_request(payload):
10
  url = "https://baxin-simulator.hf.space/protocol"
 
11
  protocol_name = generate_unique_name()
12
  data = {"name": protocol_name, "content": payload}
13
- headers = {"Content-Type": "application/json"}
14
 
15
  response = requests.post(url, json=data, headers=headers)
16
 
@@ -30,6 +32,7 @@ def send_post_request(payload):
30
  return response_data["run_status"]
31
  # ToDo if run_log option is on
32
  # return response_data["run_log"]
 
33
  else:
34
  print("Unexpected response:", response_data)
35
  return "Unexpected response"
 
1
  import gradio as gr
2
  import requests
3
  import uuid
4
+ import os
5
 
6
  def generate_unique_name():
7
  unique_name = str(uuid.uuid4()) + ".py"
 
9
 
10
  def send_post_request(payload):
11
  url = "https://baxin-simulator.hf.space/protocol"
12
+ token = os.environ['HF_TOKEN']
13
  protocol_name = generate_unique_name()
14
  data = {"name": protocol_name, "content": payload}
15
+ headers = {"Content-Type": "application/json", 'Authorization': 'Bearer {}'.format(token)}
16
 
17
  response = requests.post(url, json=data, headers=headers)
18
 
 
32
  return response_data["run_status"]
33
  # ToDo if run_log option is on
34
  # return response_data["run_log"]
35
+
36
  else:
37
  print("Unexpected response:", response_data)
38
  return "Unexpected response"