简体   繁体   中英

Is there a secure way to use React.js with a Python Flask backend for a multi-user, password protected site

I'm familiar with Flask for building simple webapps and using jinja2 as a template engine. However, I'd like to try out React.js as a front-end.

The examples I've seen that use React.js with a Python backend essentially use it as an API server to call the json needed to include in the React views. However, how does this work with authentication models and libraries for Flask? Can you mix-and-match jinja2 and React.js within the same template, to get access to the session data?

Any pointers or experience to help get started would be appreciated.

It is possible to use React.js within the Jinja2 template system. This is the solution, placing the React components within an authorised user if loop, using a library like Flask-Login.

Here's a further example I found of someone working this through: Flask and Reactjs throw JSX Transform error .

For those of you who are thinking to use react and flask to build an app, please read this article below. I used this concept for my project:

https://towardsdatascience.com/build-deploy-a-react-flask-app-47a89a5d17d9

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM