December 10

Install Flask on Ubuntu 18.04

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: with following code: 

from flask import Flask
app = Flask(__name__) 

def hello_world():     
  return 'Hello World!'

Testing the Development Server:

flask run

You should see output: $ Running on (Press CTRL+C to quit)

Just like Djangle, you can close the app and deactivate it form your VENV.

$ deactivate

Send us a message. We will reply as soon as we can.