Git Product home page Git Product logo

dash-flask-login's Introduction

dash-flask-login

dash-flask-login

This is an example of Flask-login implementation on top of a Dash application for users authentication.

The example comes with users authentication through a sqlite3 database, however you can use your own database by changing the con parameter with your database URI in the config.txt file.

The example comes with the a standard username test and password test1 but you can add more users using the add_remove_users.ipynb jupyter notebook or the functions available in the users_mgt.py.

Files description:

add_remove_users.ipynb: A jupyter notebook to help creating and removing users
app.py: The app initial screen
config.py: python script to initialize the configuration included in the config.txt file
config.txt: configuration file
requirements.in: input configuration file to be used together with pip-tools
requirements.txt: configuration file generated bypip-tools
server.py: the app initialization file
users.db: sqlite3 database with user information
users_mgt.py: helper file for the user management process

Running an app locally

To run an app locally:

  1. (optional) create and activate new virtualenv:
pip install virtualenv
virtualenv venv
source venv/bin/activate
  1. pip install -r requirements.txt
  2. flask run or gunicorn wsgi:application
  3. open http://127.0.0.1:5000 in your browser or
  4. flask run --host=0.0.0.0 or gunicorn --bind 0.0.0.0:8000 wsgi:application to open for external connections

Deployng to Heroku

  1. Install Heroku CLI: https://devcenter.heroku.com/articles/heroku-cli
  2. Login to your heroku account: heroku login
  3. Create the app: heroku create
  4. Deploy to Heroku: git push heroku master
  5. Access the app via the address provided by Heroku

Contributing

PRs accepted! Please contribute if you believe this example can be improved.

dash-flask-login's People

Contributors

rafaelmiquelino avatar samuel-tay avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dash-flask-login's Issues

File contains no section headers.

Hello,

I found some posts about dash authentication here:

https://community.plot.ly/t/get-username-for-authenticated-user-for-basic-auth/13613

and it’s almost working. I keep getting this error:

File “c:\users\User\appdata\local\programs\python\python37\lib\configparser.py”, line 696, in read
self._read(fp, filename)
File “c:\users\User\appdata\local\programs\python\python37\lib\configparser.py”, line 1079, in _read
raise MissingSectionHeaderError(fpname, lineno, line)
configparser.MissingSectionHeaderError: File contains no section headers.
file: ‘config.txt’, line: 1
‘[database]\n’

I decided to start leraning Python/Dash. I am trying to replicate stuff that I did in Excel/Vba using Dash. However I am a beginner without programming backrgoud (I worked on Excel, SAS, SAP…) so many definitions don’t say anything to me.

Also, how can I connect my main app (lets say it’s Dash.py) with your part and retrive user name?

I would very much appreciate if you could get back to me and maybe help me run your code.

BR
Krzyszsz

Dropdown menu's not working with Flask authentication

I am using this repository to create a multi-user authenticated app.

Everything seems to work fine individually, and I can get individual graphs working but when I have more than a dropdown menu the second dependent menu will not populate.
It actually appears no dropdown example will work, even the basic dropdown example.

Any help or a workaround would be greatly appreciated

Login on Enter Button press

Dear Rafael,

this is a nice project and I have a question to you.

Do you know how to "login" by pressing the "Enter" Button?

Would be great to receive support from you.

Best regards

issue with gunicorn

when I deploy this app with gunicorn and assign more than one worker, the judgement current_user.is_authenticated does not work from tome to time.
Althorough I have logged in, and the url is /success, the page content is /login_fd

Comment

Thanks for making this repo.
I found it helpful and used it to make an alternative public version that suits my needs on Gitlab.
If you want to merge my repo into yours that's fine, and just let me know.
Otherwise i'll keep it as a separate repo.

Cheers.

Elastic Beanstalk

Hi, I would like to upload an app based on your style to elastic beanstalk.

I understand that for that we need two lines
application = app.server

And then:

if name == 'main':
application.run_server(debug=True, port=8080)

when I try do this by changing "server = app.server" in serve.py to application and then using the above line it doesn't work. I was wondering if you were able to advise how to go about deploying on AWS Elastic Beanstalk.

Many thanks in advance!

current_user.is_authenticated returns false in deployment

Hello,

Thanks for making this repository.

I have been using it with success on a localhost, but as soon as I deploy it, on a hosted server, the user authentication stops behaving. As the user logs in, it registers that the user is authenticated, but within less than a 1s the bool current_user.is_authenticated is set to false.

I have tried everything, and this problem is consistent for my code, that includes the code from this repository, and if one puts this repository on a server and runs it.

Thanks and all the best,
Max H

Two proposals

Hi Rafael,

Very great job! thanks a lot.

I suggest two 2 things.

1° If you want to change the table name use " tablename" in "Class User()" as you can see below:
class User(db.Model):
tablename = 'utilisateurs'
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(15), unique=True)
password = db.Column(db.String(80))

And if you want use MySQL instead SQLite you can change the 'con' string
like this :
con = mysql+pymysql://os.environ.get('user'):os.environ.get('mpd')@localhost:3306/os.environ.get('db')

But it's not possible to interpret os.environ value and the connection failed, have you an issue for this, myself it try to use "eval" without success. I put directly the con string in SQLALCHEMY_DATABASE_URI and engine = create_engine(...)

Another little thing, config.read('config.txt') needs the current path to find the config.txt with os.chdir even the txt file is in the same directory than config.py.

Sorry for my english,

Swift

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.