Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

464
Visualizações
Flask not activating debug mode

I am getting started with flask, I am trying to follow some tutorials, but I have been unable to run Flask app in debug mode.

I tried the simplest code I found:

from flask import Flask
app = Flask(__name__)

app.debug = True
# I have also tried with a configuration
# app.config.from_object('config')
# file with constant
# DEBUG = True

@app.route('/')
def hello_world():
    return 'Hello World!'

Then I run

export FLASK_APP=hello_world.py
flask run

But I allways get this output

 * Serving Flask app "hello_world.py"
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

When I run print(app.debug) I get False

This is the output of pip freeze:

click==7.1.2
Flask==1.1.2
itsdangerous==1.1.0
Jinja2==2.11.2
MarkupSafe==1.1.1
Werkzeug==1.0.1

And I have python 3.8.2

over 4 years ago · Santiago Trujillo
6 Respostas
Responde à pergunta

0

if you are using windows just type the following in your terminal :
in PowerShell:

$env:FLASK_ENV = "development"
flask run

in command prompt :

C:\path\to\app>set FLASK_ENV=development
flask run

and for mac you probably need to run this :

$ export FLASK_ENV=development
$ flask run

enjoy !!

over 4 years ago · Santiago Trujillo Relatório

0

Try This:

When you run,

export FLASK_APP=hello_world.py

Run this command after the above,

export FLASK_DEBUG=1

Finally,

flask run

I hope this would start the debug mode.

over 4 years ago · Santiago Trujillo Relatório

0

I have tried the below steps and it worked for me.

Have added these lines of codes to my app.py file.

if __name__ == "__main__":
    app.run(debug=True)

Then I ran the program from the Terminal using the command line

python3 app.py

and it worked.

Please find the below screenshot

enter image description here

over 4 years ago · Santiago Trujillo Relatório

0

  • Make sure that you're running the right program, sometimes it happens that we're making changes in some other program and running something else.
  • Also ensure that Setting app.debug = True is altogether a different thing from setting FLASK_DEBUG mode to on.

Try this, this works at my end.

from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello World!'

if __name__ == "__main__":
    app.run(debug=True)
over 4 years ago · Santiago Trujillo Relatório

0

There are two way to run Flask App.

  • Environment Variable
  • Programmatically

    Environment Variable you need to exporting the FLASK_APP file using command for window set FLASK_APP = *(file_name)*.
set FLASK_APP = app.py`

And for mac

export FLASK_ENV=development

You can also control debug mode separately from the environment by exporting FLASK_DEBUG=1. (set command for mac and export for window)

set FLASK_APP = app.py
set FLASK_DEBUG=1

But sometimes debugger does not work on production servers. It is a major security risk to be used on production machines.

Programmatically you have to include main section on your Flask app.py main file. It will run your app in debug mode easily but do not use flask run command use only python (file_name) command.

from flask import Flask
app = Flask(__name__)

app.debug = True

@app.route('/')
def hello_world():
    return 'Hello World!'

if __name__ == '__main__':
    app.run(debug=True)   
python app.py
over 4 years ago · Santiago Trujillo Relatório

0

Apparently, because debug mode is already off, stopping and rerunning it didn't work. add the line below to app.py and save.

if __name__ == "__main__":
app.run(debug=True)

restart the editor. then run

set FLASK_DEBUG=1

then run your project

python3 app.py 
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda