0

I have a NodeJS server and I want to GET data that is coming from python with the POST method.

pythonData.js

const router = require('express').Router()
    router.get("/data",(req,res)=>{
        console.log(res)
    })
    module.exports = router

data.py

import requests
data = {"Car": "BMW","Testing":"API"}

request = requests.post("http://localhost:5000/python/data",data=data)
print(request.status_code)
print(request.text)

but when I run my python file I got an error

404

Error
Cannot POST
/python/data

Also how do I get it in my NodeJS

2 Answers 2

1

You have implemented a GET method in Node, but you are doing a POST from Python.

Try changing the router.get to router.post in your Express server.

Sign up to request clarification or add additional context in comments.

1 Comment

I want to send data from my python script to nodejs server so that I can get it there in Nodejs
1

You express router function is processing GET request. Change this to process POST request.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.