3

I would like to use python as part of a react-native project which handles heavy algorithms. However, as many have suggested, it is not recommended to do that, but simply create an API for the python.

Now firstly, I'm confused by the term "create an API", what does that mean? Is it to use something like firebase that deals with backend, and then simply use firebase api?

2 Answers 2

1

What I know (and I really don't know much) is to keep your frontend separate from your backend.

You can create the frontend React components in React. You also create API routes to your backend using e.g. python, flask, ... (firebase is a good option). Then you make HTTP requests from your frontend to your backend API to connect them together.

Sign up to request clarification or add additional context in comments.

1 Comment

While you may be right (you are), this doesn't really answer the question and rather expresses your opinion
1

In this context API is just a web server that returns JSON instead of rendering an HTML view. If you build Flask application to do that you can then read that data to your react front end using fetch or some other async tool. In this model, you would put your heavy algorithms on the server and just call them from UI action to be ran and then returned results in the mobile rendered by react-native.

Where are you planning to put those heavy algorithms? If on server side sure use Python if you want them on the actual client devise just write a native app, it will much easier. How would you use firebase for this especially with Python? Hook Firebase up with Google Cloud functions & some database then use firebase to serve results to mobile. Sounds unnecessary complex.

Here is an example tutorial how to use Flask to build the backend API if that is what you want to do. https://testdriven.io/part-one-intro

Note this is for React not React-Native so there are some differences how to fetch data.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.