Posted on :: Updated on :: Tags: , , ,

My Flask project

It feels like forever since I wrapped up my reading and doing exercises from the book Learn Python 3 The Hard Way. I tried to do as much of the exercises as I could (still got to get those exercises to my Gitea-instance). I learned a lot and even though at times it was a somewhat impossible book, it ingrained some fundamental concepts about Python into my head, like working with objects, calling and returning functions, etcetera.

The end project in that book is a text-based adventure that you turn into a web app using Flask, a well-known Python WSGI web application framework. I hit my head against that project a few times and found myself unmotivated. Then I thought, why not turn this into something I can actually use in my day-to-day life? That's what grew into my flask-soc-site project, which I have been working on for what I think is a year now. The commit history is wrong, anyway: I had to switch hardware to selfhost my websites and some stuff got lost along the way.

Packaging is hard (and feels like a hurdle to take)

The Flask SOC site, as you can now only see from a single screenshot, works nicely: it gets me relevant results on IP addresses, URLs, domains and email addresses, including SPF and DKIM information, AbuseIPDB and VirusTotal scores and details. It displays this information to me in a neat and useful manner, with a single table displaying each looked up host and a clickable drop-down that offers some more information (for now only VirusTotal vendors marking a host as malicious and some AbuseIPDB information). I thought, finally, I can ship this off to my server and put it on the already reserved sec.joostagterhoek.nl-domain.

Alas! If only it were that easy. What I didn't know was how the Flask documentation encourages you (and it's just a general best practice I guess), is to properly package your Flask app and only then host it wherever you want. The hosting part I already figured out, with some help from the YunoHost-forum (thanks for that, by the way). But the packaging? That was entirely new to me. So, I felt, once again, stuck 🛑.

Perseverance! And a lot of learning

Fortunately, I didn't try to hit my head against this problem too much before thinking: there must be some information out there on how to properly package a Flask app. And of course: RTFM. The Flask documentation site has a whole tutorial about how to properly set up, arrange and package a Flask app that I jumped onto. Not only is the tutorial teaching me a lot on how to organize your files, pick a building backend, create your configuration files and handle secrets and environment variables. It's also taught me about Flask Blueprints and Views, which I definitely should experiment with in a next or side-project. So far, I managed to get my Flask site properly organized in a separate folder. Soon I hope to reflect all these changes in my Gitea-repository, so to show my progress. It's going too slow, but never mind, I'm making progress! And that is ultimately what matters: your own progression 🏹. See you soon!