I'm having difficulty getting my flask app to run by using the "python" method. I have no problems using
export FLASK_APP=microblog.py
flask run
but attempting to use
python microblog.py
will result in the following error
ImportError: No module named 'app'
where my microblog.py file looks like this:
from app import app, db
from app.models import User@app.shell_context_processor
def make_shell_context():return {'db': db, 'User': User}
and my __init__.py
file looks like this:
from flask import Flask
from config import Config
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migratefrom flask_login import LoginManagerapp = Flask(__name__)
app.config.from_object(Config)
db = SQLAlchemy(app)
migrate = Migrate(app, db)login = LoginManager(app)
login.login_view = 'login'from app import routesif __name__ == '__main__':app.run()
The folder these files reside in is called 'app'. I've tried putting the
if __name__ == '__main__':app.run()
In the microblog.py file as well, which was also unsuccessful.
I also have folders for templates/static/etc. and a routes file where I run all my @app.route()
commands
Again, everything works fine when I run "flask run" in terminal, it just breaks down when I try using "python microblog.py". I'm trying to launch the app on AWS and just about every tutorial requires the applications to be called using the "python" method. Any help is appreciated.