[Error 500] Failed to process "..." with status: 500, without error Response
sKunZel opened this issue · 0 comments
While i'm using it locally, since i figured it out that no Endpoint URL was needed, i still don't get any success with generating songs.
I'm confronted with Error 500. Thanks in advance.
My data are formatted like that :
My current code :
import os
import requests
from dotenv import load_dotenv
from google.oauth2.service_account import Credentials
from googleapiclient.discovery import build
load_dotenv()
SCOPES = ['https://www.googleapis.com/auth/spreadsheets.readonly']
SERVICE_ACCOUNT_FILE = os.getenv('GOOGLE_APPLICATION_CREDENTIALS')
def get_google_sheets_service():
"""Create a service object for accessing the Google Sheets API."""
creds = Credentials.from_service_account_file(SERVICE_ACCOUNT_FILE, scopes=SCOPES)
service = build('sheets', 'v4', credentials=creds)
return service
def get_lyrics_from_sheet(spreadsheet_id, range_name):
"""Fetch song lyrics from a specified Google Sheet."""
service = get_google_sheets_service()
sheet = service.spreadsheets()
result = sheet.values().get(spreadsheetId=spreadsheet_id, range=range_name).execute()
values = result.get('values', [])
if not values:
print("No data found.")
return values
def send_lyrics_to_api(song_data):
url = 'http://localhost:3000/api/custom_generate'
headers = {'Content-Type': 'application/json'}
for song in song_data:
if len(song) < 3:
print(f"Incomplete data for song, skipping: {song}")
continue
payload = {
"title": song[0],
"tags": song[1],
"prompt": song[2]
}
response = requests.post(url, json=payload, headers=headers)
if response.status_code == 200:
print(f"Successfully processed: {song[0]}")
else:
print(f"Failed to process {song[0]} with status: {response.status_code}, Response: {response.text}")
if name == "main":
SPREADSHEET_ID = os.getenv('SPREADSHEET_ID')
RANGE_NAME = 'Feuille 1!A3:C'
songs = get_lyrics_from_sheet(SPREADSHEET_ID, RANGE_NAME)
if songs:
send_lyrics_to_api(songs)
else:
print("No songs found or an error occurred while fetching songs.")