Skip to content

Recently learned about flask and REST api's and jwt authentications, so created a UI in react to implement it with a better feel and also learn about connecting frontend to the backend.

Notifications You must be signed in to change notification settings

SiddharthChaberia/user-auth-flask-react

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

User Login & Registration Auth Using Flask (for logic) & React (for UI)

This is a simple login and logout app, made using react and flask. you can follow the steps below to set ths app on your own device and try out. It uses the JWT token authorization to validate the password while logging in.

The UI is kept simple, as the functionality and working was the main motive here

Folder Structure

  • 'frontend' - contains the react files
  • 'backend' - contains the flask.py file

Setup

Backend

  1. Move to 'backend' folder
    cd backend
  2. Install the python dependencies
    pip install -r requirements.txt
  3. Create a .env file to store your 'JWT_SECRET_KEY'
  4. Start the flask app
    python app.py

Frontend

  1. Move to 'frontend' folder
    cd frontend
  2. Install the node.js dependencies
    npm install
  3. Start the React app
    npm start

Testing

Now the backend is running http://127.0.0.1:5000 while the frontend is running on http://localhost:3000, both synced to each other.

Alternate Way To Run The Files (recommended)

To run the flask and react app, you need to have two terminals running at the same moment, but you can save the effort with the following set of commands. Make sure you first install the necessary dependencies and then run these steps.

  1. Move the folder where you haev backend and frontend file located and move to the terminal
    npm install -g concurrently
  2. concurrently "cd backend && python app.py" "cd backend && npm start"
  3. The above command works on Windows, but for Linux, one additionaly step is needed
    chmod +x start.sh
    And then just
    ./start.sh

Feel free to submit issues or pull requests to improve this API. Was just learning about flask and dockerfiles.

Connect with me on:

About

Recently learned about flask and REST api's and jwt authentications, so created a UI in react to implement it with a better feel and also learn about connecting frontend to the backend.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published