I have this request, on my node.js application :
return new Promise((resolve, reject) => {
const options = {
hostname: 'py', <== docker container
port: 8000,
path: '/resume',
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
file
})
}
const req = http.request(options, (res) => {
const body = [];
console.log('STATUS: ' + res.statusCode);
console.log('HEADERS: ' + JSON.stringify(res.headers));
res.setEncoding('utf8');
res.on('data', (chunk) => {
console.log('BODY: ' + chunk);
body.push(chunk);
});
resolve(body);
});
req.on('error', (error) =>{
console.log('problem with request: ' + error.message);
reject(error)
});
req.end();
})
And this, on my python app, that I copied from this topic => https://stackoverflow.com/a/65141532/14317753
@app.post("/resume")
async def resume(request: Request):
da = await request.form()
da = jsonable_encoder(da)
print('file', da)
return da
But unfortunately, da is an empty string.
Obviously, I've tried everything : changing the GET request to POST and putting the get file param into a base64 file body param, using the request.json() and the request.body() instead of request.form() for the fixes I remember.
Thanks for you help.