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
install:
test -d $(VENV) || python3 -m venv $(VENV)
$(PIP) install --upgrade --no-cache pip setuptools -e .[test]
clean:
rm -fr dist
rm -fr $(VENV)
rm -fr *.egg-info
check-outdated:
$(PIP) list --outdated --format=columns
test:
$(PYTHON) -m pytest tests.py afpy.py --flake8 --isort --cov=afpy --cov=tests --cov-report=term-missing
serve:
env FLASK_APP=afpy.py FLASK_ENV=development $(FLASK) run
isort:
$(ISORT) -rc .isort.cfg afpy.py tests.py
black:
$(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
install_requires=[
'Flask',
'Flask-Caching',
'libsass',
'docutils',
'feedparser',
'python-dateutil',
'itsdangerous',
],
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:
serve:
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 out the locale line before comitting!
Testing
For testing you will need to run black, flake8, tests.py
Top comments (2)
I think you are great! I built a display machine state using Python3 with Flask!
Flask State Github๏ผgithub.com/yoobool/flask-state .
Should i can get some improvement suggestions from you? Thanks~
XD found i already starred the project sometimes ago! Will do!