debug mode let us re starting the server automatically when we make some change.
so, edit env/bin/activate file and add environment variable FLASK_ENV with "development" value
export FLASK_ENV = "development"
debug mode let us re starting the server automatically when we make some change.
so, edit env/bin/activate file and add environment variable FLASK_ENV with "development" value
export FLASK_ENV = "development"
create application folder
by console:
mkdir my-first-flask-app
initializate environment
inside the folder ...by console:
virtualenv env
set terminal to listen our environment
source env/bin/activate
then, the word «(env)» will appear at the beginning of the prompt
install flask with his dependencies
pip3 install Flask
at the end of the installing we can list the dependencies installed by:
pip3 freeze
it will show something like this:
creating our fist Flask app...
create a file called run.py and add this content:
export FLASK_APP="run.py"
and save it.
To save this changes, we must going out from our environment
deactivate
and then, activate it again:
source env/bin/activate
now, we can start the internal server, like this:
flask run
helps us to isolate our project dependencies creating a virtual environment for every project.
installation:
sudo pip3 install virtualenv
note:
virtualenv needs to be installed with administrative or “Superuser” privileges in order for it to be installed in the right directory and for the command to be recognized
check installation:
which virtualenv
or
whereis virtualenv
both of them would get the same result:
/usr/local/bin/virtualenv
update the package list:
sudo apt update
install pip for python3:
sudo apt install python3-pip
check installation:
pip3 --version
it must response something like this:
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)