File tree Expand file tree Collapse file tree 4 files changed +39
-2
lines changed
Expand file tree Collapse file tree 4 files changed +39
-2
lines changed Original file line number Diff line number Diff line change 66#build the flask app
77
88@app .route ("/" )
9- #tells the url - nothing means everything
9+ #tells the url - currently / means home
1010def hello ():
1111 return "Hello World!"
1212
Original file line number Diff line number Diff line change 1+ #make static folder for public view
2+ #make template folder for private view
3+
4+ from flask import Flask , render_template
5+ #render_template function html ko python se link karta hai
6+
7+ app = Flask (__name__ )
8+
9+ @app .route ("/" )
10+ def template ():
11+ return render_template ("index.html" )
12+ #file location bydefault templates folder ka hota hai
13+
14+ #To link python variables to html
15+ @app .route ("/variable" )
16+ def variable ():
17+ myname = "Harsh"
18+ return render_template ("variable.html" , naam = myname )
19+ #To use this variable in html use {{naam}}
20+
21+ app .run ()
Original file line number Diff line number Diff line change 88</ head >
99
1010< body >
11+ < p > Ye template page hai< p >
1112</ body >
1213
1314
14- </ html >
15+ </ html >
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+
3+ < html >
4+
5+
6+ < head >
7+ < title > About Page</ title >
8+ </ head >
9+
10+ < body >
11+ < h1 > Hi mera naam {{naam}} hai</ h1 >
12+ </ body >
13+
14+
15+ </ html >
You can’t perform that action at this time.
0 commit comments