Thiloid commited on
Commit
f63704d
·
verified ·
1 Parent(s): a2c0830

Update run.py

Browse files
Files changed (1) hide show
  1. run.py +5 -6
run.py CHANGED
@@ -16,21 +16,20 @@ import os
16
 
17
  api_key = os.getenv("key")
18
  # Step 1: Authenticate with Hugging Face Hub
19
- api = HfApi()
20
- # Replace 'your_token' with your actual Hugging Face API token
21
- api.token = api_key
22
  # Step 2: Specify your Hugging Face username, Space name, and file name
23
  username = 'thiloid'
24
  space_name = 'envapi'
25
  file_name = 'nestolechatbot-5fe2aa26cb52.json'
26
 
27
  # Step 3: Get download URL for the JSON file
28
- download_url = f'https://huggingface.co/{username}/{space_name}/resolve/main/{file_name}'
29
 
30
  # Step 4: Download the file content
31
  try:
32
- response = requests.get(download_url)
33
- response.raise_for_status() # Raise an exception for bad responses
 
34
  except requests.exceptions.HTTPError as e:
35
  print(f"HTTP error occurred: {e}")
36
  exit()
 
16
 
17
  api_key = os.getenv("key")
18
  # Step 1: Authenticate with Hugging Face Hub
19
+
 
 
20
  # Step 2: Specify your Hugging Face username, Space name, and file name
21
  username = 'thiloid'
22
  space_name = 'envapi'
23
  file_name = 'nestolechatbot-5fe2aa26cb52.json'
24
 
25
  # Step 3: Get download URL for the JSON file
26
+ download_url = f'https://huggingface.co/{username}/{space_name}/blob/main/{file_name}'
27
 
28
  # Step 4: Download the file content
29
  try:
30
+ headers = {'Authorization': f'Bearer {api_key}'}
31
+ response = requests.get(download_url, headers=headers)
32
+ response.raise_for_status()
33
  except requests.exceptions.HTTPError as e:
34
  print(f"HTTP error occurred: {e}")
35
  exit()