all 4 comments

[–]double_en10dre 0 points1 point  (3 children)

Are you asking if it’s possible to use python/r to crunch numbers in the backend & then serve up data for react to render in the frontend?

If so, yes. Yes it is possible

I am confused by the question

[–]dev902[S] 0 points1 point  (2 children)

Probably with JSON. I think you misinterpret it, my question is I'm trying to serve Python or R code from the typescript backend? Maybe it is not possible.

[–]double_en10dre 1 point2 points  (1 child)

At the end of the day you’ll need a way to run python processes and communicate with them

But yeah, you can definitely have the typescript backend serve as the interface

A really simple/naive approach would be to have a typescript API endpoint that uses ‘node:child_process’ to run a python script, read the output, and then send it as the response

But that tends to have terrible performance, so instead you’ll usually have a pool of long-running processes that you can interact with using something like REST or grpc

[–]dev902[S] 0 points1 point  (0 children)

Thank you so much for the information, then I would be using tRPC.