I try to implement an authentification app with python, SQLAlchemy and Flask. I found https://www.digitalocean.com/community/tutorials/how-to-add-authentication-to-your-app-with-flask-login-fr.
But after I defined set FLASK_APP=project
and set FLASK_DEBUG=1
, i tried to run my app with flask run
, i get the error :
Error: Could not locate a Flask application. You did not provide the "FLASK_APP" environment variable, and a "wsgi.py" or "app.py" module was not
found in the current directory.
app.py :
from flask import Blueprint
main = Blueprint('main', __name__)
@main.route('/')
def index():
return 'Index'
@main.route('/profile')
def profile():
return 'Profile'
auth.py :
from flask import Blueprint
#from . import db
auth = Blueprint('auth', __name__)
@auth.route('/login')
def login():
return 'Login'
@auth.route('/signup')
def signup():
return 'Signup'
@auth.route('/logout')
def logout():
return 'Logout'
init.py :
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
# init SQLAlchemy so we can use it later in our models
db = SQLAlchemy()
def create_app():
app = Flask(__name__)
app.config['SECRET_KEY'] = 'secret-key-goes-here'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///db.sqlite'
db.init_app(app)
# blueprint for auth routes in our app
from auth import auth as auth_blueprint
app.register_blueprint(auth_blueprint)
# blueprint for non-auth parts of app
from app import main as main_blueprint
app.register_blueprint(main_blueprint)
return app
i exactly following the tuto and i use a venv Have you an idea ?