3

I'm using Flask-Script and I've got a manage.py that looks like this.

from mypackage import create_app
from flask.ext.script import Manager

app = create_app()
manager = Manager(app)    

if __name__ == '__main__':
    manager.run()

I'll start my app with python manage.py runserver --debug

From within manage.py, how can I find out that runserver was called with --debug?

I've tried app.debug but that returns False and manager.get_options() returns an empty list.

Everett Toews
  • 10,337
  • 10
  • 44
  • 45

1 Answers1

3

The code you've provided is fine-- here's a mypackage.py file to demonstrate that:

from flask import Flask, Blueprint, current_app

test = Blueprint('user', __name__, url_prefix='/')

@test.route('/')
def home():
    return str(current_app.debug)

def create_app():
    app = Flask(__name__)
    app.register_blueprint(test)
    return app

Adding --debug reflects accurately (True) when you access the index page.

Doobeh
  • 9,280
  • 39
  • 32