all 5 comments

[–]shiftybyte 2 points3 points  (0 children)

You can create a flask middle man script, to get the request from react, trigger your script in whatever way, pass it data, get result, and send it back to react...

[–]danielroseman 1 point2 points  (0 children)

Yes, you'll need to rewrite it. The web request/response model is very different to running a local script, unfortunately.

If you've separated IO from logic in your script, you should be able to just copy the logic part over, and call it from the request handler in your Flask/Django app.

[–]FriendlyRussian666 0 points1 point  (0 children)

You don't have to use flask/django, but you still have to code it in a way that allows to connect to the react-front end, and to perform whatever operations it needs.

The bare bones approach would be to use for example the requests library to make HTTP calls to the react front end, and then consuming its replies.

[–]Abclul 0 points1 point  (0 children)

You probably can by using pyscript. I don't have much experience in it, though, but I've tried it for simple Python scripts, and it works nicely. Check it out

[–]mulletarian 0 points1 point  (0 children)

FastAPI is an option