Created
June 3, 2020 15:19
-
-
Save yzdann/df17f5f137e1b88a919dffffb0e01c5f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>List of Links</title> | |
</head> | |
<body> | |
<h1>Links</h1> | |
<ul> | |
{% for link in links %} | |
<li><a href="{{ link }}">{{ link.split("://")[1].split(".")[-2] }}</a></li> | |
{% endfor %} | |
</ul> | |
</body> | |
</html> |
This file contains hidden or 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
from typing import List | |
from jinja2 import Environment, FileSystemLoader | |
PATH = "index" | |
def create_html_links(list_of_links: List[str]) -> None: | |
env = Environment(loader=FileSystemLoader("."), trim_blocks=True) | |
baseline = env.get_template(f"{PATH}.jinja") | |
jinja_vars = {"links": list_of_links} | |
html = baseline.render(jinja_vars) | |
with open(f"{PATH}.html", "w") as html_file: | |
html_file.write(html) | |
if __name__ == "__main__": | |
links = [ | |
"https://google.com", | |
"https://fb.com", | |
"http://telegram.me", | |
"https://api.snapp.ir", | |
"https://ipg.vandar.io", | |
] | |
create_html_links(links) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment