0
我正在嘗試nodejs第一次。我用python shell來使用它。我試圖將文件從一臺電腦傳輸到另一個使用Post請求從POST請求提取文件nodejs
app.js(服務器PC)
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.post('/mytestapp', function(req, res) {
console.log(req)
var command = req.body.command;
var parameter = req.body.parameter;
console.log(command + "|" + parameter)
pyshell.send(command + "|" + parameter);
res.send("POST Handler for /create")
});
Python文件從(客戶端PC)
f = open(filePath, 'rb')
try:
response = requests.post(serverURL, data={'command':'savefile'}, files={os.path.basename(filePath): f})
我送文件使用小提琴手和請求似乎包含在客戶端PC上的文件,但我似乎無法獲得服務器PC上的文件。我如何提取並保存文件?是因爲我缺少標題嗎?我應該使用什麼?謝謝
的感謝!但是從客戶端PC(python腳本),上傳文件的代碼是什麼? – golu
@golu不是說你問過關於如何處理上傳文件到Nodejs服務器的問題嗎? – peteb
是的,也許如此。那我還需要另外一個問題嗎? – golu