Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

235
Views
Sending python result from node js to ajax

I have a python function inside of node js server. I am trying to send the python result value from node js server to ajax.

const express = require('express');
const app = express();
const port = 8080;
var PythonShell = require('python-shell');

app.get('/', function(req, res) {
    var options = {
        mode: 'text',
        pythonPath:'',  
        pythonOptions:['-u'],
        scriptPath:'',
        args: [req.query.country]  
    };
    PythonShell.PythonShell.run('test.py', options, function(err, results) {
        if(err) throw err;
        console.log('results: ', results);
        res.send(results.toString());
    });
    res.sendFile(__dirname + '/search.html');
});
$.ajax({
    type: "GET",
    url: 'http://localhost:8080/',
    data: {country:country},
    dataType:'text',
    success: function(data) {
        console.log('data: ', data);
    }
});

I do not know which method I should use to send the result to ajax and I am not sure if the 'data' variable from ajax is proper way to use as the result which came from the server side.

Does anyone have any idea?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!