2
votes

I'm developing a small web-app using python + flask + google app engine. I was just wondering if anyone has found a better debugging workflow (with a local server) than me?

At the moment, I'm stuck between two sub-optimal approaches:

1. Use local GAE server: dev_appserver.py app.yaml

  • Con: only gives very minimal python error information

2. Use flask server: python main.py

  • Con: doesn't reload when files changed
  • Con: can't accept the same folder structure for serving local files as dev_appserver.py

My current workflow is to use dev_appserver.py until I run into python errors, at which point I edit main.py, quit dev_appserver.py, run the flask server, edit the browser address, and continue.

I've tried playing with the different dev_appserver.py logging settings, but that doesn't seem to influence whether python error messages are sent to the terminal window.

1
Flask development server does have auto-reload option Check: flask.pocoo.org/docs/0.12/quickstart/#debug-modeSohaib Farooqi
Thanks. I've added another con (!) - that the flask server doesn't seem to be able to accept the same folder structure when serving static files. For example, with GAE, I've got a nested static folder structure (/static/js, /static/css, etc.) which doesn't work with flask. So when I switch to flask, locally-served js and css files don't load, without even more faffing around.Tom M
Could you include the folder structure you're using? Flask works correctly with /static/js/ , at least for me.Luis Orduz

1 Answers

0
votes

Something like this might solve your problem:

app = Flask(__name__)

production_environment = os.getenv('SERVER_SOFTWARE').startswith('Google App Engine/')

if not production_environment:
    app.debug = True