Forums

Flask-User

Hi

I'm trying to follow this tutorial:

https://flask-user.readthedocs.io/en/latest/quickstart_app.html#

I'm assuming that the last bit about opening the URL on port 5000 isn't going to work here. I tried just pasting the code into a new file and going to it as I usually would in an app but it comes up with th following error:

2018-11-20 15:12:35,489: Error running WSGI application
2018-11-20 15:12:35,489: ImportError: cannot import name 'app' from 'flask_app' (/home/xxx/mysite/flask_app.py)
2018-11-20 15:12:35,490:   File "/var/www/xxx_pythonanywhere_com_wsgi.py", line 16, in <module>
2018-11-20 15:12:35,490:     from flask_app import app as application  # noqa
2018-11-20 15:12:35,490: ***************************************************
2018-11-20 15:12:35,490: If you're seeing an import error and don't know why,
2018-11-20 15:12:35,490: we have a dedicated help page to help you debug: 
2018-11-20 15:12:35,491: https://help.pythonanywhere.com/pages/DebuggingImportError/
2018-11-20 15:12:35,491: ***************************************************

I want to be able to add registration/login functionality to my app and this seemed like a good option.

Any ideas on how I can achieve this?

Cheers Andy

It might be much easier for you to follow this tutorial:

A beginner's guide to building a simple database-backed Flask website on PythonAnywhere

It was prepared with pythonanywhere hosting in mind. After you finish it you will be able to go beyond that and include features that are not covered there (like registration/login functionality) without much hassle. Other tutorials may be used as a convenient reference at that point.

Hi

Thanks for the link. I'm a bit further down the road though. My site is built and is driven by MySQL in the background quite a bit.

What I want to add is the ability for people to register with an e-mail address and password, then login with the details they chose.

Cheers Andy

If you're getting the exception above, then you do not have a working web app. Use the tutorial that fjl posted to get a working web app first. Then you can work through the flask-user tutorial for the specifics of getting flask-user working.

The reason for doing this was to experiment as I need to add an authentication layer to my app so that I can scale it up to multiple users.

I ended up following this tutorial:

https://pythonspot.com/login-authentication-with-flask/

I just replaced the bit where they start talking about databases with my own code to use MySQL. Works a treat :)

Next small step towards global domination is to NOT store the passwords in plain text. Mwa ha ha ha ha

Sounds like a good plan :-) BTW the second part of the tutorial @fjl linked to earlier has some code to handle that stuff, with explanatory text, so you might find it worth checking out at least as a source of ideas.