Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 737
Phil Sheard Avatar asked Feb 04 '15 06:02

Phil Sheard


1 Answers

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.

like image 107
Phil Sheard Avatar answered Oct 06 '22 01:10

Phil Sheard