I run a Python Flask server which has a few registered routes (see an example below). One route redirects the HTTP request to a WSGI application. For my project I switched to a NodeJS server and recreated the routes because Python is too slow due to its GIL.
I was in the progress of converting also the WSGI route to NodeJS but discovered, that there is not much support for it.
The WSGI protocol describes a few environment variables like wsgi.url_scheme, but on Google I can't find any examples or references about it with NodeJS (TS).
wsgi.url_scheme filetype:py 5000 Hits
wsgi.url_scheme filetype:ts 0 Hits
wsgi.url_scheme filetype:js 0 Hits
Node/TS
app.get("/wsgi", async function (req, res) {
var env = createWsgiEnvironmentFrom(req); <--- what I would need
var p = child_process.spawn('wsgi-test.exe', ["foo"],
{
stdio: [process.stdin, process.stdout, process.stderr],
env: {...env }
});
}
);
Python:
@app.route('/wsgi', methods=['POST', 'GET'])
def wsgi(path):
env = request.environ # already WSGI compatible
p = subprocess.Popen(args=["wsgi-test.exe", "foo"],
env=env,
...)
Does this have a reason? I would assume that Node is better in scaling incoming connections so I am surprised I see so little/no examples in combination with Node
Any help is highly appreciated!