Added error pages generator
This commit is contained in:
parent
c279c449df
commit
9f0353d961
9 changed files with 124 additions and 400 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +1,2 @@
|
|||
dist
|
||||
dist_error
|
||||
|
|
|
@ -1,80 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
|
||||
<title>401 - Unauthorized</title>
|
||||
|
||||
<style>
|
||||
html {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
*, *::before, *::after {
|
||||
box-sizing: inherit;
|
||||
}
|
||||
|
||||
body {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
color: #000000de;
|
||||
font-family: Inter, sans-serif;
|
||||
}
|
||||
</style>
|
||||
<style>
|
||||
html {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
h1,h2 {
|
||||
display: inline-block;
|
||||
padding: 0 .2em;
|
||||
}
|
||||
h1 {
|
||||
color: #d50000;
|
||||
}
|
||||
h2 {
|
||||
text-align: left;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
figure {
|
||||
display: block;
|
||||
border-top: 5px #dedede solid;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
blockquote::after, blockquote::before {
|
||||
font-weight: 800;
|
||||
color: #dedede;
|
||||
}
|
||||
blockquote::before {
|
||||
content: "«";
|
||||
}
|
||||
blockquote::after {
|
||||
content: "»";
|
||||
}
|
||||
|
||||
figcaption {
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
|
||||
<meta name="msapplication-TileColor" content="#ffffff">
|
||||
<meta name="theme-color" content="#ffffff">
|
||||
</head>
|
||||
<body>
|
||||
<h1>401</h1>
|
||||
<h2>Non Autorisé</h2>
|
||||
<figure>
|
||||
<blockquote cite="https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html">
|
||||
The request requires user authentication.
|
||||
</blockquote>
|
||||
<figcaption><cite>HTTP/1.1 Status Code Definitions</cite></figcaption>
|
||||
</figure>
|
||||
</body>
|
||||
</html>
|
|
@ -1,80 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
|
||||
<title>403 - Forbidden</title>
|
||||
|
||||
<style>
|
||||
html {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
*, *::before, *::after {
|
||||
box-sizing: inherit;
|
||||
}
|
||||
|
||||
body {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
color: #000000de;
|
||||
font-family: Inter, sans-serif;
|
||||
}
|
||||
</style>
|
||||
<style>
|
||||
html {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
h1,h2 {
|
||||
display: inline-block;
|
||||
padding: 0 .2em;
|
||||
}
|
||||
h1 {
|
||||
color: #d50000;
|
||||
}
|
||||
h2 {
|
||||
text-align: left;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
figure {
|
||||
display: block;
|
||||
border-top: 5px #dedede solid;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
blockquote::after, blockquote::before {
|
||||
font-weight: 800;
|
||||
color: #dedede;
|
||||
}
|
||||
blockquote::before {
|
||||
content: "«";
|
||||
}
|
||||
blockquote::after {
|
||||
content: "»";
|
||||
}
|
||||
|
||||
figcaption {
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
|
||||
<meta name="msapplication-TileColor" content="#ffffff">
|
||||
<meta name="theme-color" content="#ffffff">
|
||||
</head>
|
||||
<body>
|
||||
<h1>403</h1>
|
||||
<h2>Interdit</h2>
|
||||
<figure>
|
||||
<blockquote cite="https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html">
|
||||
The server understood the request, but is refusing to fulfill it. Authorization will not help and the request SHOULD NOT be repeated.
|
||||
</blockquote>
|
||||
<figcaption><cite>HTTP/1.1 Status Code Definitions</cite></figcaption>
|
||||
</figure>
|
||||
</body>
|
||||
</html>
|
|
@ -1,80 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
|
||||
<title>404 - Not Found</title>
|
||||
|
||||
<style>
|
||||
html {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
*, *::before, *::after {
|
||||
box-sizing: inherit;
|
||||
}
|
||||
|
||||
body {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
color: #000000de;
|
||||
font-family: Inter, sans-serif;
|
||||
}
|
||||
</style>
|
||||
<style>
|
||||
html {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
h1,h2 {
|
||||
display: inline-block;
|
||||
padding: 0 .2em;
|
||||
}
|
||||
h1 {
|
||||
color: #d50000;
|
||||
}
|
||||
h2 {
|
||||
text-align: left;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
figure {
|
||||
display: block;
|
||||
border-top: 5px #dedede solid;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
blockquote::after, blockquote::before {
|
||||
font-weight: 800;
|
||||
color: #dedede;
|
||||
}
|
||||
blockquote::before {
|
||||
content: "«";
|
||||
}
|
||||
blockquote::after {
|
||||
content: "»";
|
||||
}
|
||||
|
||||
figcaption {
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
|
||||
<meta name="msapplication-TileColor" content="#ffffff">
|
||||
<meta name="theme-color" content="#ffffff">
|
||||
</head>
|
||||
<body>
|
||||
<h1>404</h1>
|
||||
<h2>Introuvable</h2>
|
||||
<figure>
|
||||
<blockquote cite="https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html">
|
||||
The server has not found anything matching the Request-URI.
|
||||
</blockquote>
|
||||
<figcaption><cite>HTTP/1.1 Status Code Definitions</cite></figcaption>
|
||||
</figure>
|
||||
</body>
|
||||
</html>
|
|
@ -1,80 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
|
||||
<title>500 - Internal Server Error</title>
|
||||
|
||||
<style>
|
||||
html {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
*, *::before, *::after {
|
||||
box-sizing: inherit;
|
||||
}
|
||||
|
||||
body {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
color: #000000de;
|
||||
font-family: Inter, sans-serif;
|
||||
}
|
||||
</style>
|
||||
<style>
|
||||
html {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
h1,h2 {
|
||||
display: inline-block;
|
||||
padding: 0 .2em;
|
||||
}
|
||||
h1 {
|
||||
color: #d50000;
|
||||
}
|
||||
h2 {
|
||||
text-align: left;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
figure {
|
||||
display: block;
|
||||
border-top: 5px #dedede solid;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
blockquote::after, blockquote::before {
|
||||
font-weight: 800;
|
||||
color: #dedede;
|
||||
}
|
||||
blockquote::before {
|
||||
content: "«";
|
||||
}
|
||||
blockquote::after {
|
||||
content: "»";
|
||||
}
|
||||
|
||||
figcaption {
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
|
||||
<meta name="msapplication-TileColor" content="#ffffff">
|
||||
<meta name="theme-color" content="#ffffff">
|
||||
</head>
|
||||
<body>
|
||||
<h1>500</h1>
|
||||
<h2>Erreur Serveur Interne</h2>
|
||||
<figure>
|
||||
<blockquote cite="https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html">
|
||||
The server encountered an unexpected condition which prevented it from fulfilling the request.
|
||||
</blockquote>
|
||||
<figcaption><cite>HTTP/1.1 Status Code Definitions</cite></figcaption>
|
||||
</figure>
|
||||
</body>
|
||||
</html>
|
|
@ -1,80 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
|
||||
<title>502 - Bad Gateway</title>
|
||||
|
||||
<style>
|
||||
html {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
*, *::before, *::after {
|
||||
box-sizing: inherit;
|
||||
}
|
||||
|
||||
body {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
color: #000000de;
|
||||
font-family: Inter, sans-serif;
|
||||
}
|
||||
</style>
|
||||
<style>
|
||||
html {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
h1,h2 {
|
||||
display: inline-block;
|
||||
padding: 0 .2em;
|
||||
}
|
||||
h1 {
|
||||
color: #d50000;
|
||||
}
|
||||
h2 {
|
||||
text-align: left;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
figure {
|
||||
display: block;
|
||||
border-top: 5px #dedede solid;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
blockquote::after, blockquote::before {
|
||||
font-weight: 800;
|
||||
color: #dedede;
|
||||
}
|
||||
blockquote::before {
|
||||
content: "«";
|
||||
}
|
||||
blockquote::after {
|
||||
content: "»";
|
||||
}
|
||||
|
||||
figcaption {
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
|
||||
<meta name="msapplication-TileColor" content="#ffffff">
|
||||
<meta name="theme-color" content="#ffffff">
|
||||
</head>
|
||||
<body>
|
||||
<h1>502</h1>
|
||||
<h2>Passerelle Défectueuse</h2>
|
||||
<figure>
|
||||
<blockquote cite="https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html">
|
||||
The server, while acting as a gateway or proxy, received an invalid response from the upstream server it accessed in attempting to fulfill the request.
|
||||
</blockquote>
|
||||
<figcaption><cite>HTTP/1.1 Status Code Definitions</cite></figcaption>
|
||||
</figure>
|
||||
</body>
|
||||
</html>
|
46
generate_errors.py
Normal file
46
generate_errors.py
Normal file
|
@ -0,0 +1,46 @@
|
|||
from pprint import pp
|
||||
from pathlib import Path
|
||||
from urllib import request
|
||||
import re
|
||||
|
||||
src = Path('src')
|
||||
root = src.joinpath('error')
|
||||
with root.joinpath('root.html').open('r') as root_file:
|
||||
root_html = root_file.read()
|
||||
with root.joinpath('root.css').open('r') as root_file:
|
||||
root_css = root_file.read()
|
||||
|
||||
error = Path('dist_error')
|
||||
error.mkdir(exist_ok=True)
|
||||
|
||||
for x in error.rglob('*'):
|
||||
if x.is_file() or x.is_symlink(): x.unlink()
|
||||
|
||||
req = request.Request(
|
||||
'https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html',
|
||||
method='GET')
|
||||
|
||||
with request.urlopen(req) as res:
|
||||
raw = res.read().decode('utf-8')
|
||||
|
||||
codes = (re.finditer(r"(?s)<h3><a id='sec10\.[0-9]\.[0-9]+'>"
|
||||
r'10\.[0-9]\.[0-9]+</a>'
|
||||
r'\s*([0-9]+)\s([a-zA-Z\s]+)</h3>\s*<p>(.*?)</p>', raw))
|
||||
|
||||
nginx_head = ''
|
||||
nginx_body = ''
|
||||
|
||||
for item in codes:
|
||||
code, title, desc = item.groups()
|
||||
if int(code) < 300 or int(code) >= 600: continue
|
||||
with error.joinpath(f'{code}.html').open('w') as html:
|
||||
html.write(root_html.format(code=code, title=title, desc=desc, style=root_css))
|
||||
nginx_head += f'error_page {code} @error{code};\n'
|
||||
nginx_body += f'location @error{code} {{\n'\
|
||||
f'root {error.resolve()};\n'\
|
||||
f'try_files /{code}.html /{code}.html;\n'\
|
||||
'internal;}\n'
|
||||
|
||||
with error.joinpath(f'nginx.conf').open('w') as nginx_file:
|
||||
nginx_file.write(f'{nginx_head}\n{nginx_body}\n\n'\
|
||||
'proxy_intercept_errors on;')
|
51
src/error/root.css
Normal file
51
src/error/root.css
Normal file
|
@ -0,0 +1,51 @@
|
|||
html {
|
||||
box-sizing: border-box;
|
||||
text-align: center;
|
||||
}
|
||||
*, *::before, *::after {
|
||||
box-sizing: inherit;
|
||||
}
|
||||
|
||||
body {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
color: #000000de;
|
||||
font-family: Inter, sans-serif;
|
||||
}
|
||||
|
||||
h1,h2 {
|
||||
display: inline-block;
|
||||
padding: 0 .2em;
|
||||
}
|
||||
h1 {
|
||||
color: #d50000;
|
||||
}
|
||||
h2 {
|
||||
text-align: left;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
figure {
|
||||
display: block;
|
||||
border-top: 5px #dedede solid;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
blockquote::after, blockquote::before {
|
||||
font-weight: 800;
|
||||
color: #dedede;
|
||||
}
|
||||
blockquote::before {
|
||||
content: "«";
|
||||
}
|
||||
blockquote::after {
|
||||
content: "»";
|
||||
}
|
||||
|
||||
figcaption {
|
||||
text-align: right;
|
||||
}
|
26
src/error/root.html
Normal file
26
src/error/root.html
Normal file
|
@ -0,0 +1,26 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
|
||||
<title>{code} - {title}</title>
|
||||
|
||||
<style>
|
||||
{style}
|
||||
</style>
|
||||
|
||||
<meta name="msapplication-TileColor" content="#ffffff">
|
||||
<meta name="theme-color" content="#ffffff">
|
||||
</head>
|
||||
<body>
|
||||
<h1>{code}</h1>
|
||||
<h2>{title}</h2>
|
||||
<figure>
|
||||
<blockquote cite="https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html">
|
||||
{desc}
|
||||
</blockquote>
|
||||
<figcaption><cite>HTTP/1.1 Status Code Definitions</cite></figcaption>
|
||||
</figure>
|
||||
</body>
|
||||
</html>
|
Reference in a new issue