-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5e0a968
commit 3f210a4
Showing
2 changed files
with
84 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from jinja2 import Template, Environment | ||
from datetime import datetime | ||
|
||
|
||
def render_html(template_name, context): | ||
# Read the Jinja2 template file | ||
with open(template_name, 'r') as file: | ||
template_content = file.read() | ||
|
||
# Create a Jinja2 template object | ||
template = Template(template_content) | ||
|
||
# Render the template with custom values | ||
rendered_html = template.render(**context) | ||
|
||
# Write the rendered script to the output file | ||
with open('index.html', 'w') as file: | ||
file.write(rendered_html) | ||
|
||
if __name__ == "__main__": | ||
context = { | ||
'year_list': ["2021", "2022"], | ||
'month_list': ["01", "02"], | ||
'day_list': ["01", "02", "03"], | ||
} | ||
render_html('index_vrfy_marine.html.j2', context) |