How to Install Flask in Ubuntu?

Share:

Flask is a microframework of Python and if you are a beginner and you want to set-up of the flask in your Linux system then this tutorial for you.

In this tutorial, we will install flask till project app directories, in our Debian based operating system.
Now, just open your Terminal (CTRL+ALT+T) and ready to install Flask step by step.

Python Online Training by Edureka
1.Create An Application Directory using git:

$ git clone https://github.com/miguelgrinberg/flasky.git
$ cd flask 

2.Create a virtual environment with python3
   You are now going to create a virtual environment inside the flask directory.

$ sudo apt-get install python3-venv
$ python3 -m venv virtual-environment-name
$ python3 -m venv venv

3.Working with virtual Environment and activate source files in created flaky directory:

$ source venv/bin/activate
Now, You can see your virtual environment created and you see like this in your terminal

4.Installing Python Packages with pip

(venv) $ pip3 install flask

after installing flask using pip then if you want to show your all dependencies, just type :

(venv) $ pip freeze

click==6.7
Flask==0.12.2
itsdangerous==0.24
Jinja2==2.9.6
MarkupSafe==1.0
Werkzeug==0.12.2


Now, You can check or verify that you installed or not flask in your system

 (venv) $ python3
 >>> import flask
 >>>
If you show no error appear, now you can congratulate yourself that you ready to work on flask framework
5.Create your first project in flask and save it e.g (hello.py)
  

6. Start your Development Server

(venv) $ export FLASK_APP=hello.py
(venv) $ flask run
* Serving Flask app "hello"
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

Now, open your browser and paste this  http://127.0.0.1:5000/and if you got it, congratulate yourself.
If you face any problem just comment in the comment box and please don't hesitate to contact us.  

No comments