I would like to create a Makefile
for my python flask application in order to make it easier to use.
So I have this directory named myproject
which contains:
> 07/28/2021 02:30 PM <DIR> .
> 07/28/2021 02:30 PM <DIR> ..
> 07/27/2021 01:30 PM 3,275 hello.py
> 07/28/2021 02:37 PM 311 Makefile
> 07/27/2021 11:13 AM <DIR> static
> 07/22/2021 04:24 PM <DIR> Templates
> 07/22/2021 02:23 PM <DIR> venv
> 07/27/2021 01:31 PM <DIR> __pycache__
I would like to execute my python flask project easily with a Makefile.
When I want to start my project I have to set these command lines in the folder myproject
:
for
window
venv\Scripts\activate
set FLASK_APP=hello
flask run
for
linux/mac OS
. venv/bin/activate
export FLASK_APP=hello
flask run
I would like to put them in a Makefile and give the possibility to make it work for windows AND linus/mac os when running make
.
Here is the Makefile I have:
PY = python3
VENV = venv
BIN=$(VENV)/bin/activate
#make it work on windows too
ifeq ($(OS), Windows_NT)
BIN=$(VENV)/Scripts/activate
PY=python
endif
all:
make env && \
make debug && \
flask run
env:
set FLASK_APP=hello.py
debug:
set FLASK_ENV=development
(my python file is named hello.py
)
but when I run make
when I am in the folder myproject
i have the following error:
'make' is not recognized as an internal or external command, operable program or batch file.