How to fix error 500. POST method not working

Hello friends! Could you please help me deploy my artificial intelligence model on Glitch server? My model works perfectly on my computer when I run the local server using the command ‘python app.py’, but when I uploaded my model to Glitch hosting and installed all the necessary libraries, I faced an issue that Glitch does not support the POST method.

You can check it yourself, here is my AI model for predicting the cost of transporting cargo from point A to point B considering the weight of the cargo.

app.py

hidden

client.py

hidden

data.csv

cargo,cost,distance
100,200,10
200,400,20
300,600,30
400,800,40
500,1000,50

dataframe.py

import pandas as pd

Define the data as a dictionary

data = {
‘distance’: [10, 20, 30, 40, 50],
‘cargo’: [100, 200, 300, 400, 500],
‘cost’: [200, 400, 600, 800, 1000]
}

Create a pandas DataFrame from the dictionary

df = pd.DataFrame(data)

Save the DataFrame as a CSV file

df.to_csv(‘data.csv’, index=False)

my_model.py

hidden

predict.py

from app import get_distance

start = ‘10005’
end = ‘10006’

distance = get_distance(start, end)

print(“The distance between {} and {} is {} miles”.format(start, end, distance))

start.sh

python app.py

index.html

HTML here:

https:// chip-nine-wallflower.glitch . me/

(remove spaces)

I sat for 15 hours in a row in this project but did not figure it out. imma going to sleep. I am hope for your help!

:face_with_head_bandage:

can you open the logs to see if Glitch is actually running your app? I think it needs to have a requirements.txt file to recognize it as a python project.

Hello! Yes, I also have this file. Nothing in the logs, no errors. My model just doesn’t work, look here

https://chip-nine-wallflower.glitch.me/

It throws an error, but there is nothing in the logs

I filled in some dummy data and got a 500 error. so it seems you’ve gotten past the 405 issue?

Yes, now there is a 500 error. I still can’t find a solution to the problem. There is nothing in the logs

look in the HTTP response body

There is only such an error in the console, which I can not solve in any way

POST https://chip-nine-wallflower.glitch.me/predict 500

:face_exhaling:

Hmm, I uploaded the model.pkl file. But for some reason it appears in the “Assets” section and I cannot transfer it to the root directory. How can this problem be solved in Glitch? :eyes:

here’s some instructions for getting it into the project from assets. not sure if a .pkl file will show in the editor, but it’ll still be there

Hello! I have uploaded the file model.pkl to the root directory, but unfortunately it did not help to solve the problem, as I still get a 500 error. Maybe I am doing something wrong?

I’m getting "unsupported pickle protocol: 3" in the error details.

see if you can get that to show up in your network inspector. it looks like you have a filter only showing “Other” requests, you may have to clear that to show the request to /predict

I found what the problem is, this is a problem on the Glitch side. The thing is, my model works on GET and POST methods, but POST method doesn’t work in Glitch.

Glitch only uses this: HEAD, DELETE, GET, PUT.

Hmm, I don’t want to change hosting, I like Glitch, but what should I do in this situation?

oh did it go back to giving 405?

No, I’m getting a 505 error because the POST method doesn’t work on Glitch. Glitch only uses this: HEAD, DELETE, GET, PUT.

Is it possible how to solve this problem? I don’t want to change hosting :pensive:

I’m still getting HTTP 500, not 405 nor 505. is there something different you’re doing to get 405?

My mistake, typo. Error 500* This 500 error occurs because the POST method that my model uses does not work on Glitch. Any ideas how to solve this error?

Or will I have to change the hosting that supports the POST method? I don’t want to do this :frowning::persevere:

no, that was the description of HTTP 405 though

side note:

what site was that screenshot from? Glitch’s help site looks different, and it doesn’t mention POST not being supported.

https://help.glitch.com/kb/search/?q=HTTP%20405

I contacted Glitch support, I fixed the 405 error. But now the error is 500, they also told me that Glitch doesn’t support the POST method. But my model uses POST and GET methods. What do you think I need to do? Change hosting to run my model?

weird, they’re wrong about that. even the starter project uses POST. are you sure you didn’t mistakenly get in contact with some other service’s support?

don’t worry, the problem looks like it has a pretty simple solution. you’re just not able to see the problem right now. you’ll probably get it right away when you see it. I won’t spoil it for you. for now you just have to sort out your sources of information and filter out the bad actors dragging you in the wrong directions.

1 Like