25 lines
711 B
Python
25 lines
711 B
Python
import sys
|
|
|
|
file = open("errorpage_template.html", "r")
|
|
template_html = file.read()
|
|
|
|
error_pages = {
|
|
"400": "Bad Request",
|
|
"401": "Unauthorized",
|
|
"403": "Forbidden",
|
|
"404": "Not Found",
|
|
"405": "Method Not Allowed",
|
|
"413": "Payload Too Large",
|
|
"418": "I'm a teapot",
|
|
"429": "Too Many Requests",
|
|
"500": "Internal Server Error",
|
|
"503": "Service Unavailable",
|
|
"522": "Connection Timed Out",
|
|
"599": "Network Connect Timeout Error"
|
|
}
|
|
|
|
for error, description in error_pages.items():
|
|
f = open(f"{sys.argv[1]}/{error}.html", "w")
|
|
html = template_html.replace("{{code}}", error).replace("{{description}}", description).replace("{{title}}", f"{error} {description}")
|
|
f.write(html)
|
|
f.close() |