0

I intend to use Python to generate an HTML code that will be saved to an external file. The HTML code will display the current day. No Javascript nor PHP allowed. How can I make the Python code repeat every day after midnight, so that the corresponding HTML file will contain a valid day in a week info? Thank you. My code:

import datetime
t=datetime.datetime.now()

s="""<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>Daily Portal</title>
</head>
<body>

<div>{maininfo:}</div>
 
</body>
</html>"""


s1=t.strftime("%A")
s2="Good morning John. Today is "+s1+"."+" Have a beautiful day."

s=s.format(maininfo=s2)

print(s)
Jan
  • 1
  • 4

1 Answers1

0

You can set a job scheduler to execute the code everyday. Refer here and here (if you are running on a unix system).

fractal397
  • 534
  • 1
  • 5
  • 11