Flask CORS abort?

If you use CORS, you need to add ‘Allow origin’ header to the response. But don’t forget: also any error responses need the ‘Allow Origin’ header. So even if you add the header to the response, if you have a Abort, also add this header to the abort response.

Sadly, you can’t directly. You must supply a new error handler taking over abort() based on error code and add the extra headers in the error handler. Not that hard, but still.

But there is another issue if you use flask restful. Flask Restful takes over flask error handling and you can’t supply your own headers to errors handled by Flask restful.

Best is to avoid abort() if you need to add specific headers to the abort response. Create your own exception instead and raise that exception which stops the current request. Handle your own exceptionclass in the flask errorhandler @app.errorhandler and add the extra headers there.

Besides POST, also take care of the headers during the additional OPTION request performed by browsers such as chrome.


Loving Indents

Anyone inspecting code will notice details by scanning indents.

Can web please embrace python?


Parallax scrolling hero with Boostrap4 and just a few lines of code.

Imagine the following plain bootstrap4 HTML snippet. Wouldn’t it be great if we could turn this into a fancy scrolling parallax hero with fading text using less than 15 lines of css and js and NO extra requirements?

Below the css/main.css file (6 lines including css semantics)

And the Javascript js/script.js. Without this step, you would be stuck with a normal hero instead of the neat parallanimated one (8 lines js + 6 lines css, makes 14 lines).

That’s it. Below the Bootstrap 4 demo page. Parallax needs something to scroll, so that’s why we need some extra Lorem Ipsum paragraphs. Besides that it’s just bootsrap4 together with minimal html.


Server deployment pgAdmin 4.5 on Windows Server 2019 and Apache with mod_wsgi.

pgAdmin 4 is a great web based database management tool for postgres. Besides the possibility to use it as client-side tool, it is also possible to install it serverside and have clients login to pgAdmin so they don’t need local installations.

This does involve some steps though, and the docs won’t guide you from A to Z. You can find the pgAdmin server deployment documents here. gives a good start. But there is nothing about compiling mod_wsgi

We start on a fresh Windows server 2019. We will also install postgres itself on the same server so we can test the setup.

A fresh Windows server installation will be pretty locked down and also IE is configured in super-safe mode. We could modify this IE behaviour, but I choose to download and use chrome instead for the rest of this walktru.

Although pgAdmin has a stand-alone webserver built-in, this is not suitable for production. We will use and configure Apache as our webserver. pgAdmin is a python flask webapplication and we will use the Apache mod_wsgi plugin to dispatch requests from Apache to the python pgAdmin web application.

The mod_wsgi plugin isn’t available in most Apache binaries. You will need to build them yourself. This is easy though, since we will use python’s pip to install.

Besides windows, I will use 32 bit installations of the software all the way. The reason for this is is that the pgAdmin dependencies are 32 bit and we need those. Therefore our mod_wsgi should also be 32 bit and Apache should also be 32 bit. I think it would be possible to create a 64 bit version if we would take care of the dependencies ourselves, but I keep it simple and just use 32 bit versions.

So, inside pgAdmin there is a python 32-bit virtual environment with all the packages and dependencies needed to run the web application. Including Python itself. But because we use apache to run the webapplication code, we also need a regular python 32-bit installation on the machine. Besides, that this installation is also needed to build our mod_wsgi later on.

Let’s give it a try.

Python 3.7 (32-bit)

Download and install from:

Make sure to choose a 32 bit binary. For example:
Windows x86 executable installer

After installation, we need to add two folders to PATH so that you can use python and pip from the commandline. From windows search enter ‘Env’ and the option ‘Edit the system environment variables’.

The settings will pop-up. Choose ‘Environment Variables’ and look for the line that says ‘Path’ under ‘System variables’ (the 2nd list, not the top one).

In my case, the paths needed for Python are below, but of course i won’t use ‘administrator’ in a real-world scenario. Add these to your environment variables with the correct <username> folder.


Python installation is done.


Download pgAdmin 4 for windows from

At the time of this writing, the version is 4.5.

Install using default options. This installation will create a default setup, dat doesn’t matter, but we will override it so we have more control over folders etc.

When default installation is done, create the following folders:

mkdir C:\pgAdminData\sessions
mkdir C:\pgAdminData\storage

Next, we need to prepare the new configuration. First go to the pgAdmin directory.

cd C:\Program Files (x86)\pgAdmin 4\v4\web

Now in this directory, create a file and enter the following:

LOG_FILE = 'C:\pgAdminData\pgadmin4.log'
SQLITE_PATH = 'C:\pgAdminData\pgadmin4.db'
SESSION_DB_PATH = 'C:\pgAdminData\sessions'
STORAGE_DIR = 'C:\pgAdminData\storage'

The IP adress ‘’ makes sure that we will be able to reach the server from the outside world instead of Localhost only.

Now it is time to do run Our fresh python installation doesn’t have the dependencies needed to run this file, but the bundled python virtual environment does have the correct dependencies. A virtual environment sounds fancy, but it is just a folder with python and installed dependencies.

For each virtual environment there is an activation script that just temporarily changes the PATH’s so that we can use it. This is nice, because it is isolated, and won’t break when you install something for your main python environment.

But… the included activation script for windows doesn’t work out of the box, probably caused by the build tools used by the developers. Luckily for us the script just needs a minor fix for our purpose. First go to the venv folder inside pgAdmin.

cd C:\Program Files (x86)\pgAdmin 4\v4\venv\Scripts

Now in notepad, change the first path (line 2) to the correct directory. So from:

set "VIRTUAL_ENV=C:\jenkins\workspace\pgadmin4-windows-build\win-build\venv" 


set "VIRTUAL_ENV=C:\Program Files (x86)\pgAdmin 4\v4\venv

And save. Now we shoud be able to go to the top-level directory and activate the virtual environment. Then we can run our with the correct dependencies.

You will be prompted for initial username/password. Save this, you need it when you run pgAdmin. Finally we can deactivate the virtual environment.

> cd C:\Program Files (x86)\pgAdmin 4\v4\
(venv)> python web\
(venv)> deactivate

Now, we won’t be using the venv itself when running the webapplications. We will use the Python that we installed on the computer. But we do want want to take advantage of the python dependencies that are bundled inside the pgAdmin application.

Therefore we need to add some code to the very top of “C:\Program Files (x86)\pgAdmin 4\v4\pgAdmin 4\web\pgAdmin4.wsgi”.

activate_this = 'C:/Program Files (x86)/pgAdmin 4/v4/venv/Scripts/'
 with open(activate_this) as file_:
     exec(, dict(file=activate_this))

Be careful. It must be entered at the beginning of pgAdmin4.wsgi. And also there are some similar examples of ‘activate_this’ code that try to do the same, but somehow won’t work.

What this code does, is executing the activate_this script. This script makes sure that the venv dependencies are available to your main python application when mod_wsgi executes ‘pgAdmin4.wsgi’.

Apache Webserver

pgAdmin has it’s own webserver (provided by python Flask) but that won’t be sufficient for real-world scenario’s. Therefore we will install the world’s famous webserver Apache. It will handle the requests from the client browsers and send them to pgAdmin later on.

Apache doesn’t provide windows installers since quite a while, and we don’t want to build Apache ourselves. Luckily Apache Lounge provides windows installers. Go to and download the latest win32 version. It downloads as zipfile. At this moment of this writing, the following version is the latest.

Extract it to C:\Apache24. Make sure this is the application directory directly, so no extra subfolders. We could start Apache by hand, but let’s install it as a service.

cd C:\Apache24\bin
httpd.exe -k install -n "Apache HTTP Server"

We will need do extra configuation, but first we need to build and install mod_wsgi. I couldn’t find a pre-built version of mod_wsgi, but we can use Python’s pip to built it for us. I think it is the easiest way.


By itself, Apache doesn’t know how to execute python code. For this we need a plugin called mod_wsgi. It WSGI is capable of doing more than that, but let’s focus on getting pgAdmin running.

Because we installed the correct version of Python and we have the paths setup correctly, installing mod_wsgi is super easy. But, we need one other tool first: Microsoft Build Tools for C++. We require a version that is equal or greater than the compiler version indicated by Apache’s download link. As we recall that was VC15 matches the build tools for Visual Studio 2017. But if you install the latest version, for example 2019, you are safe.

These steps should probably be prepared on a machine other than the production machine because we need this only once.

Download the installer here:

This page shows many downloads. Look for the one that says
‘Build Tools for Visual Studio 2019’. Download and install.

During installation, you’ll see many options to install. Just click c++ build tools end leave the options on the right as shown below. Hit install.

Now we are ready to build mod_wsgi. Open up a new cmd prompt and enter the following command:

pip install mod_wsgi

This takes a few seconds. mod_wsgi is installed as python module. Now we are ready to further configure Apache so that Apache will be able to communicate with python and execute the pgAdmin code.

Apache Configuration

Let’s fix the Apache configuration. Most of the configuration is in ‘httpd.conf’. But we will also setup a virtual host that listens on port 5050 and that requires a few changes in httpd-vhosts.conf.

Navigate to “C:\Apache24\conf” and open “httpd.conf” in notepad or any other text editor. Look for the line that says “#Include conf/extra/httpd-vhosts.conf”. Remove the “#”.

Keeping “httpd.conf” open, also open a new command prompt. The mod_wsgi installation has a function that creates the correct apache configuration for you. Enter the following command:

mod_wsgi-express module-config

This will show three lines of configuration (might be wrapped to more visual lines). Copy these three lines and enter them at the end of ‘httpd.conf’. Mine looked like this (again, it might appear more than 3 lines in your browser ;-))

LoadFile "c:/users/administrator/appdata/local/programs/python/python37-32/python37.dll"
LoadModule wsgi_module "c:/users/administrator/appdata/local/programs/python/python37-32/lib/site-packages/mod_wsgi/server/mod_wsgi.cp37-win32.pyd"
WSGIPythonHome "c:/users/administrator/appdata/local/programs/python/python37-32"

This configuration also shows where “mod_wsgi.cp37-win32.pyd” resides. You might need it if you move to production and don’t want to recompile on the production machine itself.

Save the file and open “C:\Apache24\conf\extra\httpd-vhosts.conf”. Remove everything and enter the following:

Listen 5050
<VirtualHost *:5050>
    WSGIScriptAlias / "C:\Program Files (x86)\pgAdmin 4\v4\web\pgAdmin4.wsgi"
    <Directory "C:\Program Files (x86)\pgAdmin 4\v4\web">
            AllowOverride all
            Require all granted

Save the file, Apache configuration is done.


What would be the use of pgAdmin when there is no postgreSQL database. Installing postgreSQL is easy. Here we can use the 64 bit version, that doesn’t matter.

We will install data into C:\pgData\ so create that folder first.

mkdir C:\pgData

Download version 11 from After download is finished , start installation. Choose all options. At one point you’re asked for the Data directory. Change that to our new folder “C:\pgData”.

Keep de default port and locale. And remember your password, it is used for connecting to your DB.

At the end, launch Stack Builder. In Stack Builder choose the database.

On the next screen, only select the psqlODBC drivers and install those (optional).

That is it. Installation done!

Start Apache and visit pgAdmin

Start apache using the C:\Apache24\bin\ApacheMonitor.exe.
Navigate to http://localhost:5050. First launch might take a while. Then you need to login using the credentials you entered during the execution of ‘’ when doing the pgAdmin installation.

If you want to use it from another client, make sure to open port 5050 on the server’s firewall.

A bumpy ride

Not that hard, in the end, but it took me a while to connect all dots.

I initially mixed 32 bit and 64 bit components which just didn’t work. Also I spent a while getting the virtual environment to do what I want to be able to run

Finally the code I had for running ‘’ inside pgAdmin4.wsgi was not working. Also it was not clear where to put the code in the file. In the end I copied the code from the python Flask documentation (which is the framework used by pgAdmin) and there was also the hint to put it at the very top of the wsgi file.


XAMPP VM extra Mount

In my previous post i created virtual folders outside the /opt/lampp structure. One downside is that I can only reach this over FTP now, since mounting doesn’t work. This is not handy for development.

But it turns out it is quite easy to add extra mount points.

First, shutdown XAMPP on your mac. Open the file $home/.bitname/stackman/machines/xampp/metadata.json.

Copy the “root” volume (including braces), and change accordingly for the ‘my-lampp’ folder we created earlier. Like this:

Do the same thing in /Applications/

Now in the client, (ssh open terminal) change etc/exports, so vi /etc/exports and copy /opt/lampp line to new line and change /opt/my-lampp.

Now if you open XAMPP and start the machine you’ll see the extra mount point and you should be able to open it.

Using XAMPP ssh terminal, you probably need to give more permissions to /opt/my-lampp in order to create files from your host. chmod -R a+w /opt/my-lampp for example.



Xampp vm is great out of the box, but let’s try to push it some more.

This is this setup:

  • Download and install XAMPP VM for Mac
  • SSH into the box (button ‘Open Terminal’ on front page). Now we have a terminal on the client. The following commands are in this terminal.
  • Create a new folder /opt/my-lampp
  • cd /opt/my-lampp, mkdir default, mkdir -p projects/project1
  • chown -R daemon:daemon my-lampp
  • Using vim, create a index.html in /opt/my-lampp/default with only text ‘default’ and /opt/my-lampp/projects/project1 with only text ‘project1’
  • Install vim: apt-get update, apt-get upgrade and then apt-get install vim.
  • vi /opt/lampp/etc/httpd.conf, uncomment ‘ Include etc/extra/httpd-vhosts.conf’ (remove #).
  • Save 😡
  • vi /opt/lampp/etc/extra/vhosts.conf and match the following. Be careful , these settings will also prevent 404’s when using laravel etc. So don’t skip directory permissions.

save using 😡

Now edit ftp settings. vi /opt/lampp/etc/proftpd.conf and change /opt/lampp/htdocs to /opt/my-lampp (file contains 2 entries)

On your host (your mac, not the xampp terminal), create a mapping for dev.project1 in /etc/hosts. You need ‘sudo vi /etc/hosts’.

My Xampp runs on (yours might end different, Xampp shows IP on ‘General’). Add one extra lines in /etc/hosts for the new sites.

Now from host restart the services (services tab in Xampp)

Browse to, this should show ‘default’. Browse to http://dev.project1. This shows ‘project1’. You can add more and more virtualhost projects to the server using the same procedure.

Install filezilla and create a new connection to User daemon, password xampp. You will land into /opt/my-lampp as the root of the ftp.

Lets install wordpress. Download and unpack wordpress. Connect Filezilla and put the unpacked wordpress inside /default. When uploading is finished, wordpress to the name of your site.

Browse to localhost:8080 (enable Network->port forwarding in Xampp) and go to phpmyadmin. Create a database.

Browse to http://dev.default/wordpress. Install. DB user is root, password will be empty. Just enter the info and you’re done.


Jasper Report Server 7.1 no login FF and Chrome (i18 issue)

I was giving Jasper Report Server 7.1.1 a try for the first time. But after installing, the login button was not working. So I had a look, and chrome shows that a “dateTimeSettings” file could not be downloaded (500).

I went to Firefox. Same thing. But Internet Explorer was working, and the file could be downloaded. I started to look for logs and finally found something in “./jasperreports-server-cp-7.1.1\apache-tomcat\webapps\jasperserver\WEB-INF\logs\jasperserver.log”

java.lang.RuntimeException: Settings has incorrect format: /* Dutch (UTF-8) initialisation for the jQuery UI date picker plugin. */
/* Written by Mathias Bynens <> */
	$ = {
		closeText: 'Sluiten',
		prevText: '←',
		nextText: '→',
		currentText: 'Vandaag',
		monthNames: ['januari', 'februari', 'maart', 'april', 'mei', 'juni',
		'juli', 'augustus', 'september', 'oktober', 'november', 'december'],
		monthNamesShort: ['jan', 'feb', 'mrt', 'apr', 'mei', 'jun',
		'jul', 'aug', 'sep', 'okt', 'nov', 'dec'],
		dayNames: ['zondag', 'maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag'],
		dayNamesShort: ['zon', 'maa', 'din', 'woe', 'don', 'vri', 'zat'],
		dayNamesMin: ['zo', 'ma', 'di', 'wo', 'do', 'vr', 'za'],
		weekHeader: 'Wk',
		dateFormat: 'dd-mm-yy',
		firstDay: 1,
		isRTL: false,
		showMonthAfterYear: false,
		yearSuffix: ''};

Internet Explorer is sending nl-NL as first language which doesn’t exist and falls back to ‘en’ which is working. While FF en Chrome send ‘nl’, so that was the difference and causing issues. Now I started looking at the particular files that contain these settings. I found them in “.\jasperreports-server-cp-7.1.1\apache-tomcat\webapps\jasperserver\scripts\bower_components\jquery-ui\ui\i18n”.

I compared the dutch “jquery.ui.datepicker-nl.js” with the english version. There I saw that the initialization format was a bit different ($.datepicker.regional[‘en’] vs $ So I modified accordingly. Now chrome and FF also work. Watch out, these files are actually on two different places inside the installation. Make sure to correct the right one in the folder I mentioned.

/* Dutch (UTF-8) initialisation for the jQuery UI date picker plugin. */
/* Written by Mathias Bynens <> */
	$.datepicker.regional['nl'] = {
		closeText: 'Sluiten',
		prevText: '←',
		nextText: '→',
		currentText: 'Vandaag',
		monthNames: ['januari', 'februari', 'maart', 'april', 'mei', 'juni',
		'juli', 'augustus', 'september', 'oktober', 'november', 'december'],
		monthNamesShort: ['jan', 'feb', 'mrt', 'apr', 'mei', 'jun',
		'jul', 'aug', 'sep', 'okt', 'nov', 'dec'],
		dayNames: ['zondag', 'maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag'],
		dayNamesShort: ['zon', 'maa', 'din', 'woe', 'don', 'vri', 'zat'],
		dayNamesMin: ['zo', 'ma', 'di', 'wo', 'do', 'vr', 'za'],
		weekHeader: 'Wk',
		dateFormat: 'dd-mm-yy',
		firstDay: 1,
		isRTL: false,
		showMonthAfterYear: false,
		yearSuffix: ''};

I will try to create a bug report for Jasper Report Server, but their account creation is’nt sending me a confirmation email which i need.


Blender even thickness inset

When you apply an inset on a rectangular plane that is scaled, the inset width along x will differ from the inset width along y

If you want an even thinkness, you need to apply the scaling before using inset (I). Than inset width will be the same on all axis.

What happens during “Apply->Scale” (edit mode) can be explained by an example. A plane with size x=1 and y=1 and scale y=2 would look rectangular. But is actually the scaling applied to y=1. During “apply scale”, the size is recalculated based on the scale. So in this case: size x=1 and y=2 and scale will be reset to y=1.


Locally backup and restore Docker images




Quark modify resources

In Quark Xpress or Copydesk (I am using 2015) it is not possible to modify any keyboard shortcuts from a configuration. And sometimes that is really anoying.

Luckily it is possible to modify the resources in the .exe or, if you have a language specific configuration, one of the Language___.dll’s.

The program I use is Resource Hacker:

When you start that, it is possible to open the QuarkXpress.exe (or Copydesk, or the Language___.dll’s)

First lookup the menu item you want to apply the keyboard shortcut to (look in the first node from the ‘MENU’ folder on the left). Especially the number that comes after the name of the menu item. Eg. 810 is the number for Guidelines.

Then look for ‘Accelerators’ on the left. In case of copydesk i needed to open node 500.
Look for VK_F7 and apply one of the options for 810, if it is not there add it and copy the commands from another key.

Make sure you don’t create conflicts!

Then compile and save.