How to run a Flask Linux-only App on Windows – The AFPy Site

There are in the Python world many Flask Linux-only apps. However in many case, with some twerking we can make them work on Windows. We’ll take the case of the AFPy site.

First fork the AFPy site

Then clone it

git clone https://github.com/<your-username>/site.git

The makefile looks like this

VENV = $(PWD)/.env
PIP = $(VENV)/bin/pip
PYTHON = $(VENV)/bin/python
FLASK = $(VENV)/bin/flask
ISORT = $(VENV)/bin/isort
BLACK = $(VENV)/bin/black

all: install serve

    test -d $(VENV) || python3 -m venv $(VENV)
    $(PIP) install --upgrade --no-cache pip setuptools -e .[test]

    rm -fr dist
    rm -fr $(VENV)
    rm -fr *.egg-info

    $(PIP) list --outdated --format=columns

    $(PYTHON) -m pytest tests.py afpy.py --flake8 --isort --cov=afpy --cov=tests --cov-report=term-missing

    env FLASK_APP=afpy.py FLASK_ENV=development $(FLASK) run

    $(ISORT) -rc .isort.cfg afpy.py tests.py

    $(VENV)/bin/black afpy.py tests.py

.PHONY: all install clean check-outdated test serve isort black

We also do not see any requirements.txt but see them listed in setup.py


We need to install the package to get the setup working

First setup a virtual environment. If you checked the .gitignore you will see that it is not the usual github one. You will need to add venv/ to it. See reapplying gitignore. Let’s name our virtual environment venv

python -m venv venv

Then we install the package

pip install -e .

Flask apps use flask run to run. But first some variables must be set. From the makefile:

    env FLASK_APP=afpy.py FLASK_ENV=development $(FLASK) run

Translated to batch

set FLASK_APP=afpy.py
set FLASK_ENV=development

On running you can see a locale error. You can comment it out and rerun.

The AFPy promotes Python in the French world and is a combination of many organising bodies

Note of caution: recomment our the locale line before comitting!


For testing you will need to run black, flake8, tests.py