DEV Community

Discussion on: Using Elasticsearch with Python and Flask

Collapse
 
karantrivedi profile image
KaranTrivedi

I used this code and basically got an error on 127.0.0.1:5000 saying index doesnt exist. I tried to hit 127.0.0.1:5000/insert_data and got a 405, not allowed. WHat am I missing?

Collapse
 
kamilliano profile image
kamilliano

Hi, I didn't follow the code nor run it locally. But from what you describe is that when you hit 127.0.0.1:5000/insert_data you invoke GET request and that route only accepts POST so you get not allowed error. You probably would need to do curl -H 'Content-Type: application/json' -X PUT -d '[JSON]' http://127.0.0.1:5000/insert_data where JSON is your data matching your es schema.