Forums

POST 500 internal server error Django, Fetch

I am using the Fetch Api to send data from the frontend to backend and I am not saving any data into a database. When I ran my project locally, all the Fetch calls worked perfectly fine but now that I have deployed I am getting a Server error 500 whenever a POST request is being made.

In my server log, I have print statements that run in the backend and I can see those print statements being printed in the error log implying that this does reach the backend. I can also see that the correct data is being passed to the backend. However I am still getting a POST 500 (internal server error)

This is the code for my fetch call:

const data = new FormData();
data.append('image', files[0])
fetch('/api/itot/', {
  method: 'POST',
  body:data
})
  .then(response => response.json())
  .then(data => changeCurrent(data["text"]))

The above is for an image file as input.

Here is another fetch call with only passing to the backend text and recieving a modified version of that text back:

const data = {text: currentText};
  fetch('/api/input/', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify(data)
    })
    .then(response => response.json())
    .then(data => props.changeText(data["text"]))
    .then(() => props.changeLoadingStatus(false))

In both examples, data["text"] would be what I would want to display with the frontend.

I can also include the error log or server log if needed.

Thanks for any insight.

It seems like this is one of the main reasons why this is happening.

PermissionError: [Errno 13] Permission denied: '/home/shaanluthra/Swift-Summarizer/api/tesseract-OCR/tesseract.exe'

I am using Pytesseract but I am not able to access permission to /home/shaanluthra. I really have no clue why I am being denied permission.

Responded here