![](/img/trans.png)
[英]Send text data from flutter to flask api and webview the returned html
[英]Send data from Nodejs API to Flask APi
所以我在 Nodejs 和 Flask 中創建了一個小應用程序。 我創建了 2 個 API。 第一個從 Nodejs 應用程序發送數據到 Nodejs API 然后將數據從 Nodejs API 發送到 flaskZ8A5DA59AAZ7C319C3206A7F10C17C3B9116D4A957646Z1A78AAZ7D10574E。 我在將數據從節點 Api 發送到 Flask Api 時遇到了一些麻煩。
//從Node.js api發送數據到Flask Z72664DC0959F3B0C048391F8C7046A
app.get('/postoflask', (req, res) => {
request('http://localhost:3030/users', (error, response, bodyParser) => {
if(error) {
res.send(' erorr occured')
}
else {
res.send(bodyParser)
request.post('http://localhost:5000/adduser')
}
});
});
Deploying the route on the browser retrieves the data from the node Api database and pushes null values to the flask api database. 我需要將從節點 Api 檢索到的數據原樣傳輸到 flask 數據庫的數據庫中。
端口 3030/users 是從數據庫中獲取數據的節點 api,端口 5000/adduser 是 flask api 將數據推送到數據庫中。
我是中級程序員的入門,但我不知道我在這里缺少什么或我不理解什么。 幫助將不勝感激。 使用的數據庫是 PostgreSql。
您可以利用請求 stream 功能將數據從 Node.js 端點代理到 Flask:
app.get('/postoflask', (req, res) => {
request('http://localhost:3030/users')
.on('error', (err) => {
console.log(err);
})
.on('end', () => {
res.send('done')
})
.pipe(request.post('http://localhost:5000/adduser'));
})
您沒有在request.post('http://localhost:5000/adduser')
中發送任何數據,請嘗試
request.post('http://localhost:5000/adduser',{...})
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.