Working with flask template

  • Create few templates(name: index.html,result.html)
  • Create a folder give access to template(folder name- templates)

First open your visual studio code — in visual studio code – view – TERMINAL

Activate your virtualenv – venv/scripts/activate

Run program- python class.py

Create two file – index.html and result.html

Create folder – templates (move both file “index.htmland result.html inside templates folder )

(and template folder move to flask folder(make sure your main folder))

index.html

Result.html

Create new file “class2.py”

Run your python file

python class.py

Copy paste IP address your browser:

Working with models

  • Creating a variable to data.
  • Accessing the variable from our template.

Create one variable

Result.html :- also we change in html file

Run program: python class2.py

Output:- hello mr “harry”

Open chat