Tag archive for: Python 3

How to setup Ubuntu Classic Server 16.04 on Raspberry Pi 3 for running Python 3 applications

Most of the customers who wanted to try out my minimal viable products (MVP) would provide me with an instance of Ubuntu Classic Server 16.0x these days. As such, it makes sense for me to trial my MVPs on the Ubuntu Classic Server 16.0x to ensure that I spend minimal time in deploying my MVPs to validate my customers’ needs. Since I have a few Raspberry Pi 3s lying around in the house, I can install a version of Ubuntu Classic Server 16.0x to serve as the development server for me to trial my MVPs.

Fortunately, the good folks at ubuntu-pi-flavour-maker.org had put up an optimised Ubuntu Classic Server 16.04 image for Raspberry Pi 3.

This post documents the steps that I took to run Ubuntu Classic Server 16.04 on my Raspberry Pi 3 for running Python 3 applications.

How to serve static files with Python 3 + Flask

Python Flask is a good microframework for building a minimal viable product to validate our ideas on the Internet. A modern web application encompasses documents that tell the web browser how to build the visuals of our web application and communicate with our server backend. Such documents are usually static in nature and are served as they are to the web browser without any processing from the server end.

Comparing setting up an instance of the Nginx server with adding code in our Flask application, the latter can be a more convenient way for us to realise our minimal viable product. This post documents the proof of concept that I did to serve static files with Python 3 and Flask.

How to traverse all folders and files within a folder dynamically in Python 3

I had this requirement where I need to be able to look into a folder and pick up any configuration files for my Python 3 application. In order to achieve that, I first set an exploratory task to get the Python 3 code for traversing all folders and files within a folder.

For this exploratory task, I had created a script that will traverse the folders and files that are contained within a folder and print out their full paths.

How to get the directory path of a Python 3 script from within itself

One of the best way to reference files in Python scripts is to based the file path on the directory where the Python script resides in. This will allow us to always reference our files correctly no matter where our Python script is being executed.

This post documents the Python 3 code that I often used to get the directory path of a Python 3 script from within itself.