Check your Python version:
$ python -V
$ python3 -V
Run your Flask app with python 3. You can set your defaul python with python3 if that is what you want with a simple HACK: $ sudo ln -s /usr/bin/python3 /usr/bin/python
Best to run your app in venv, install python venv if not in your system:
sudo apt install python3.x-venv
Create your project folder and create new virutal env:
$ mkdir my_flask_app
$ cd my_flask_app
$ python3 -m venv venv
Run your venv:
$ source venv/bin/activate
Install flask with pip, and check the version:
(venv) $ pip install Flask
(venv) $ python -m flask --version
Create a minimal version of Flask app; example: hello.py with following code:
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello World!'
Testing the Development Server:
export FLASK_APP=hello.py
flask run
You should see output: $ Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
Just like Djangle, you can close the app and deactivate it form your VENV.
$ deactivate