By the way, if you’ve never used Python’s debugger, it really is as simple as adding a call to the built-in function breakpoint()
at the point you want it to stop.
Tag: Python
Flask on Elastic Beanstalk
I had a play with Elastic Beanstalk the other day. It’s one of those things people turn their noses up at, but it seems pretty good for prototyping and small things. My biggest issue so far has been that, for Python applications, it expects a WSGI callable called application
in the file application.py
… but I was using Flask, and every single Flask application ever has a WSGI callable called app
in the file app.py
. I tried to not care, but it got too much after about an hour so I went and found how to override it:
$ cat .ebextensions/01_wsgi.config option_settings: aws:elasticbeanstalk:container:python: WSGIPath: "app:app"
Thank you Nik Tomazic for that! (=⌒‿‿⌒=)
Python hacking
Python‘s had this handy logging module since July 2003. A lot of things use it, so if you’re trying to understand or debug some Python code then a handy snippet to insert somewhere is:
import logging logging.basicConfig(level=1)
Those two lines cause all loggers to log everything to the console. Check out the logging.basicConfig docs to see what else you could do.