'Return data from html file with variable

I have a python file like this :

data = "data is there"
with open('index.html', 'r+') as f:
  index = f.read()
  return index

My index.html is like this :

<html>'+data+'</html>

Actual Output

<html>'+data+'</html>

Wanted output

<html>data is there</html>

EDIT: As specified in the comment, this answers my question : light weight template engine for python



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source