Giter Site home page Giter Site logo

app-generator / sample-flask-auth-session Goto Github PK

View Code? Open in Web Editor NEW
21.0 3.0 10.0 35 KB

Flask User Authentication - Open-source Sample | AppSeed

Home Page: https://blog.appseed.us/flask-user-authentication-free-sample/

License: Other

Python 39.74% CSS 1.75% HTML 58.52%
appseed-sample flask-sample

sample-flask-auth-session's Introduction

Open-source Flask project that implements a simple authentication system using Flask-Login library - Features:

  • Up-to-date dependencies
  • ✅ Authentication layer: Flask-Login
  • ✅ UI: Bootstrap5 via CDN
  • ✅ Free Support via Email and Discord.

Build from sources

Step #1 - Clone sources (this repo)

$ # Clone the sources
$ git clone https://github.com/app-generator/sample-flask-auth-session.git
$ cd sample-flask-auth-session

Step #2 - Create a virtual environment

$ # Virtualenv modules installation (Unix based systems)
$ virtualenv env
$ source env/bin/activate
$
$ # Virtualenv modules installation (Windows based systems)
$ # virtualenv env
$ # .\env\Scripts\activate

Step #3 - Install dependencies

$ # Install requirements
$ pip3 install -r requirements.txt

Step #4 - Set Up Environment

$ # Set the FLASK_APP environment variable
$ (Unix/Mac) export FLASK_APP=run.py
$ (Windows) set FLASK_APP=run.py
$ (Powershell) $env:FLASK_APP = ".\run.py"

Step #5 - Create Tables (SQLite persistance)

$ # Create tables
$ flask shell
$ >>> from app import db
$ >>> db.create_all()

Step #6 - (optional) Enable DEBUG Environment (local development)

$ # Set up the DEBUG environment
$ # (Unix/Mac) export FLASK_ENV=development
$ # (Windows) set FLASK_ENV=development
$ # (Powershell) $env:FLASK_ENV = "development"

Step #7 - Start the project

$ # Run the application
$ # --host=0.0.0.0 - expose the app on all network interfaces (default 127.0.0.1)
$ # --port=5000    - specify the app port (default 5000)  
$ flask run --host=0.0.0.0 --port=5000
$
$ # Access the app in browser: http://127.0.0.1:5000/

Flask User Authentication - Free sample provided by AppSeed.


Code-base structure

The project has a super simple structure, represented as bellow:

< PROJECT ROOT >
   |
   |-- app/
   |    |-- static/
   |    |    |-- <css, JS, images>    # CSS files, Javascripts files
   |    |
   |    |-- templates/
   |    |    |
   |    |    |-- index.html           # Index File
   |    |    |-- login.html           # Login Page
   |    |    |-- register.html        # Registration Page
   |    |    
   |    |
   |   config.py                      # Provides APP Configuration 
   |   forms.py                       # Defines Forms (login, register) 
   |   models.py                      # Defines app models 
   |   views.py                       # Application Routes 
   |
   |-- requirements.txt
   |-- run.py
   |
   |-- ************************************************************************

Resources



Flask User Authentication - Free sample provided by AppSeed.

sample-flask-auth-session's People

Contributors

app-generator avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

sample-flask-auth-session's Issues

Something's up with the requirements...

Error: While importing 'run', an ImportError was raised:

Traceback (most recent call last):
File "/Users/tomsmith/markingapp5000/env/lib/python3.9/site-packages/flask/cli.py", line 256, in locate_app
import(module_name)
File "/Users/tomsmith/markingapp5000/run.py", line 6, in
from app import app, db
File "/Users/tomsmith/markingapp5000/app/init.py", line 10, in
from flask_login import LoginManager
File "/Users/tomsmith/markingapp5000/env/lib/python3.9/site-packages/flask_login/init.py", line 16, in
from .login_manager import LoginManager
File "/Users/tomsmith/markingapp5000/env/lib/python3.9/site-packages/flask_login/login_manager.py", line 24, in
from .utils import (login_url as make_login_url, _create_identifier,
File "/Users/tomsmith/markingapp5000/env/lib/python3.9/site-packages/flask_login/utils.py", line 13, in
from werkzeug.security import safe_str_cmp
ImportError: cannot import name 'safe_str_cmp' from 'werkzeug.security' (/Users/tomsmith/markingapp5000/env/lib/python3.9/site-packages/werkzeug/security.py)

(env) Toms-MBP:markingapp5000 tomsmith$ python
Python 3.9.9 (main, Nov 21 2021, 03:23:42)
[Clang 13.0.0 (clang-1300.0.29.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

from werkzeug.security import safe_str_cmp
Traceback (most recent call last):
File "", line 1, in
ImportError: cannot import name 'safe_str_cmp' from 'werkzeug.security' (/Users/tomsmith/markingapp5000/env/lib/python3.9/site-packages/werkzeug/security.py)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.