Created
May 18, 2021 17:38
-
-
Save Thesola10/a071e2da6281dba40aeff13ffd730589 to your computer and use it in GitHub Desktop.
Generate a static redirect page. Can be useful on IPFS for link shortening for instance.
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
#!/usr/bin/env python3 | |
# mk302 by Karim Vergnes <me@thesola.io> | |
# License: CC0 1.0 Universal | |
# Requires Jinja2 | |
'''<html> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta http-equiv="REFRESH" content="0;url={{ href }}"" /> | |
<script>window.location.href="{{ href }}"</script> | |
<title>Redirecting...</title> | |
</head> | |
<body> | |
<h1>Redirecting...</h1> | |
<p>This page redirects to <a href="{{ href }}">{{ href }}</a>.</p> | |
</body> | |
</html>''' | |
if __name__ == "__main__": | |
import sys | |
from jinja2 import Template | |
if len(sys.argv) != 2: | |
print("Usage: %s <url>" %sys.argv[0]) | |
sys.exit(1) | |
template = Template(__doc__) | |
result = template.render(href=sys.argv[1]) | |
print(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment