Flask basics – setting environment variables

Lots of Flask tutorials recommend setting environment variables to protect any private information stored in the settings of the app. This is good advice, it only takes a moment of inattention to commit sensitive information to your GIT repo and then push it to a public place such as GitHub. If you’re using a virtualenv […]

Adding a shutdown button to your Raspberry Pi Flask App

If you’re running a Flask App on your Raspberry Pi in Kiosk mode you may find that you want to add a shutdown button to the ensemble so that you can switch the Pi off safely without having to SSH into it and manually issue the shutdown command. Based on Adding a Shutdown Button to […]

Flask basics: lose the favicon 404

If the fact that the Flask development server cant find your favicon annoys you shove your favicon into your static folder and do this: NOTE: this is one of several ways of getting rid of that particular error and is the one I’m using today. I’ll add more as I use them.

Flask basics: dynamically adding form elements

Sometimes you want to dynamically add elements to forms if certain information pre-exists. In this instance I wanted to add an option change the information displayed but I didn’t want the form fields to be there all the time and it was neater to simply not render them than remove them using JavaScript. First, I […]

Silly strings: passwords in Python

I’ve been playing with Flask a lot in the last few days. If you’re going to do anything with sessions in Flask you first need to generate a secret key which you use to cryptographically sign the session. I got a tad bored of mashing the keyboard to generate them so I wrote a short script to […]