I cannot set the FLASK_APP variable after restructuring it into a package, it gives an error Could not locate a Flask application. Use the 'flask --app' option, 'FLASK_APP' environment variable, or a 'wsgi.py' or 'app.py' file in the current directory.
Below is the file organization,
And the contents of the __init__.py are as follows which is in the package flaskblog as shown above.
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
app= Flask(__name__)
app.config['SECRET_KEY']= ''
app.config['SQLALCHEMY_DATABASE_URI']='sqlite:///site.db'
db= SQLAlchemy(app)
from flaskblog import routes
And the contents of the run.py are as follows
from flaskblog import app
if __name__ =='__main__':
app.run(debug= True)
I want to set the FLASK_APP environment variable so that I can activate the SQLite database using flask shell. However while setting the (.venv) PS C:\Users\sample projects\flask_blog> set FLASK_APP=flaskblog
I get
Usage: flask shell [OPTIONS]
Try 'flask shell --help' for help.
Error: Could not locate a Flask application. Use the 'flask --app' option, 'FLASK_APP' environment variable, or a 'wsgi.py' or 'app.py' file in the current directory.
But the python run.py gets executed.
You can try to change your env variables like
bash
powershell
And also i wouldnt call
__run__.py, i would call simplyrun.py