-1
is appearing, "Nameerror: name 'app' is not defined" my codic
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///storage.db'
db = SQLAlchemy(app)
migrate = Migrate(app, db)
manager = Manager(app)
manager.add_command('db', MigrateCommand)
from app.controllers import default
from app import manager
if __name__ == '__main__':
manager.run()
Remembering that name is a special python variable that references the script that is running, if that is the main script, then it will return the string main.
– Erick Kokubum
worse, which is app = flask(name)
– Indiano11
I made some changes, some tests and now it appears : Usage: run.py [-? ] {db,shell,runserver} ... positional Arguments: {db,shell,runserver} db Perform database Migrations shell Runs a Python shell Inside Flask application context. runserver Runs the Flask Development server i.e. app.run() optional Arguments: -?, -help show this help message and Exit
– Indiano11
Okay, come on, how are you running it? "python name.py" only? If you do this it will pass you the default commimands, because the manager is used so that you pass arguments through the command line, which can be the "runserver" that works as a "flask run", the "shell" that starts a python shell so that you can import what you need and run, or go straight through a decorator. Check out this doc link in the Defaults Commands section : https://flask-script.readthedocs.io/en/latest/
– Erick Kokubum