[Hindi] Static and Templates folder - Web Development Using Flask and Python #3

In this video, I have explained the reason for using static and templates folder in Flask.

Flask uses its template folder for storing the raw templates which can be filled through the python program. The static folder on the other hand contains the public content like the images, css, javascript and other files. These files can also be viewed using the www.website-url/static address.

You can view the static folder of codewithharry website by going to static folder of this website as an exercise.

I hope you will like this video. Make sure to tell me what you think about this flask series and what you would like to see next in this series?

#tut1.py file as described in the video

from flask import Flask, render_template
app = Flask(__name__)

@app.route("/")
def hello():

    return render_template('index.html')

@app.route("/about")
def harry():
    name = "rohan das"
    return render_template('about.html', name2= name)
app.run(debug=True)

#index.html file as described in the video

<!DOCTYPE html>
<html>
<head>
	<title>Title of my page</title>
</head>
<body>
<img src="{{ url_for('static', filename='1.png') }}">


<p>In this video, I have shown you how to create a flask app using templates. I have used render template function from the Flask Module</p>
<p>Hope you will like this video!</p>

</body>
</html>

#about.html file as described in the video

<!DOCTYPE html>
<html>
<head>
	<title>Title of my page</title>
</head>
<body>

<h1>Hi I am {{ name2 }}!</h1>

<p>This is a way for me to teach you flask nicely</p>
</body>
</html>


Comments(2)

white_devil at 2019-06-23 09:30:09 says
harry bhai mujhe problem ho raha hai yr course sickne me can you help me out plzzzzzzzzzzzzzzzzzzzzz
Ambikasharma at 2019-06-23 09:30:09 says
Harry Bhai when i run this code it showing error-jinja2.exceptions.TemplateNotFound jinja2.exceptions.TemplateNotFound: index.html plz explain why it showing.