I wanted to understand how to host a simple Flask app inside a Docker container, so I went through the following exercise. In the future, I would use something more like the tiangolo/uwsgi-nginx-flask docker image.
It took me a while to get Sphinx documentation set up correctly. Since it is highly configurable, it is highly easy to not configure correctly. In this guide I’ll assume that you’re using a Python virtual environment, and that you’ve placed the source code that you want to document in a directory called
src/. I’ll walk through installing and configuring what you need to create documentation from inline comments using the Google or NumPy style, and create API documentation for a Flask server. I’ll be extra-explicit about what directory I’m in when I make calls that make assumptions about the working directory.
Vagrant is a tool that you can use to set up, configure, and access a VM through the command line. This is a life changer. I love it. In this post I’ll walk through setting up an OEL6 virtual machine, installing a non-ancient version of Python, and configuring the port forwarding so that you can use it for backend web development. (The port forwarding is not obvious on RHEL/OEL.)
In this post I’ll provide an example of using session management in Flask. This is useful when you need to recover persistent data across different endpoints in your application. In this example, we set the
permanent attribute of the
session object to
True in order to ensure that the session data lasts indefinitely until it is cleared when the user accesses the root endpoint again. The best practice is to have a timeout on the session data.
In this post I’ll provide a simple example of serving a page with Flask and feeding SVG instructions into a Jinja template through an HTML form.