使用请求和套接字将数据从python传输到NodeJ

使用请求和套接字将数据从python传输到NodeJ,python,node.js,socket.io,python-requests,Python,Node.js,Socket.io,Python Requests,我尝试将数据从一个简单的python程序发送到一个节点服务器。但是没有成功。这就是为什么我要寻求帮助 我的简单python: import requests SIGNUP_URL = 'http://localhost:8000/timer' def submit_form(): obj = {name:'whateever'} resp = requests.post(SIGNUP_URL, data = obj) if _

我尝试将数据从一个简单的python程序发送到一个节点服务器。但是没有成功。这就是为什么我要寻求帮助

我的简单python:

import requests

SIGNUP_URL = 'http://localhost:8000/timer'

def submit_form():
        obj = {name:'whateever'}
        resp = requests.post(SIGNUP_URL, data = obj)        
        
if __name__ == '__main__':
            submit_form()
我的nodejs(轻,我不删除关注行):

因此,当我执行python时,我希望将数据“name:whatever”传输到服务器,然后我希望服务器将数据写入控制台(以确保数据被正确发送),并且我一切正常,我希望将这些数据发送到我的html页面。。。 谢谢你的帮助。

答案是:

python代码:

import requests

SIGNUP_URL = 'http://localhost:8000/timer'

def submit_form():
        obj = {'name':'whateever'}
        resp = requests.post(SIGNUP_URL, data = obj)        
        
if __name__ == '__main__':
            submit_form()
nodejs代码:

app.post('/timer', function(req, res){                 
    res.sendFile(__dirname + '/public/status.html');
    var info= req.body;
    io.emit('messageFromServer', info);
    console.log(info)
});
它起作用了

app.post('/timer', function(req, res){                 
    res.sendFile(__dirname + '/public/status.html');
    var info= req.body;
    io.emit('messageFromServer', info);
    console.log(info)
});