What is Flask?

in blurtutorials •  4 years ago 

Flask is a light weight web application backend Python framework.
Need basic knowledge of python.
It is easy to learn and maintain complex application easily.
It is one of the best python framework.
It have 52.3k stars on github,which is an achievement in itself.

flask (1).webp

source:https://flask.palletsprojects.com/en/1.1.x/

How to install flask

Step 1) first we have to make a virtual environment.It helps in avoiding conflict between packages and save all packages that are used in this app

a) To install virtual environment

pip(it is a package installer for python)

pip install virtualenv

b)Create virtual environment

Type command
virtualenv env (env => Name of virtual environment)

b) To activate virtual environment type command in terminal

python -m venv env

it will create a virtual(seperate) environment for our project.

Step 2) Now after this we have to install flask

now go to terminal type command

pip install flask

Step3) After installing flask create basic app

Capture11.PNG

from flask import Flask,request (we are importing library from flask)

app=Flask(__name__) (initializing a flask app)

@app.route('/')
def hello()
return "Hello !"

To run a flask app in localhost we have to use a command in terminal

set FLASK_APP=app.py

after that run another command

flask run

Capture12.PNG

Now in browser type command

localhost:5000

it will give a hello World page

Capture3.PNG

we are ready with basics of flask to make a web app

Thanks for reading.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE BLURT!
Sort Order:  

congratulations , your post has been upvoted manually by @tomoyan and @kamranrkploy.
Continue to contribute here and earn more.

  ·  4 years ago  ·  

Thanks