import requests
# Define the API endpoint and the API key
API_LINK = 'https://api.getvalenceai.com/emotionprediction'
API_KEY = 'YOUR_API_KEY'
# Define the file path to upload
file_path = "YOUR_FILE"
# Open the file in binary mode
with open(file_path, 'rb') as file:
# Prepare the files parameter with the file object
files = {
'file': file
}
# Prepare the headers with the API key
headers = {
'x-api-key': API_KEY
}
# Make the POST request to upload the file
response = requests.post(API_LINK, files=files, headers=headers)
# Check the response status
if response.status_code == 200:
print("Response:", response.json())
else:
print(f"Failed to upload file, {response.status_code}, {response.text}")