【发布时间】:2019-04-07 01:18:48
【问题描述】:
我对 node.js 非常熟悉,我知道有一个 node.js 函数叫做 req.url。我现在尝试使用 python 脚本并想使用它的等价物。有人知道是什么吗?
编辑: 这是我在 node.js 中的意思的一个例子:
app.get('/', (req, res) => {
res.send(req.url); //will return the current url
});
编辑2: 我正在使用 node.js 来执行 http 请求和东西。这是一个例子。 节点:
app.get('/', (req, res) => {
const spawn = require('child_process').spawn;
const py = spawn('python', ['python.py']);
});
蟒蛇:
url = '' #get url here
print(url)
【问题讨论】:
-
您是指来自回调函数的
req参数的url属性,例如http.createServer(function(req, res) { ... });? -
取决于您使用的库/框架,但通常是
path -
我没有使用任何框架
-
那你是怎么处理http请求的呢?你的蟒蛇是什么?你能给我们看看代码吗?
-
对不起,如果不清楚,我正在使用 node.js 中的
child_process模块来激活我的 python 代码。我将编辑问题