Forums

DEBUG = True has no effect (using flask)

Hello I'm really stuck, I try to enable debug because my page keeps saying "Unhandled Exception" instead of showing the debug page when there's an error in my code.

I'm using flask and in my flask_app.py (main application) I have the following lines which (I believe) should enable DEBUG mode for my application:

DEBUG = True
app = Flask(__name__)
app.config.from_object(__name__)

When I try this with python and flask locally on my computer it works fine. Because I'm a beginner with both flask and pythonanyware.com I use this tutorial http://flask.pocoo.org/docs/tutorial/introduction/ where I also find that the above code should do.

Can someone please give me a hint? I really try hard to understand what I'm doing incorrectly here...

Thanks very much in advance.

Hello timecode, welcome to PythonAnywhere (and flask :)

Okay, well the first thing I will say is that your webapp has built in error logs for you to read. You can find them on the web tab. The link will be something like timecode.pythonanywhere.com.error.log

Now, I don't think flask's debug mode works on PythonAnywhere. From the documentation: "the interactive debugger does not work in forking environments (which makes it nearly impossible to use on production servers)".

But if you want to give it a go, then try following the documentation and do:

app.debug = True

I don't see it telling you to set a variable called DEBUG to True anywhere in those docs. Though perhaps it's a different version?

Hello hansel

Ok I tried

app.debug = True

but it didnt help =(

Looks like I will have to use those logs, but this ok for me too. Thank you for your help!

Yeah, the docs are pretty clear about it not working in forking environments. Which PythonAnywere definitely is.