diff --git a/.gitignore b/.gitignore
index 02ba98c..850d7f0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
anthracite
+src/error_pages/
diff --git a/Dockerfile b/Dockerfile
index 67ee81b..ee549a6 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,6 +1,6 @@
FROM alpine as build-env
-RUN apk add --no-cache build-base
+RUN apk add --no-cache build-base python3
COPY ./src/ .
RUN make build-release
diff --git a/src/Makefile b/src/Makefile
index 2cfb102..d4409a7 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,6 +1,7 @@
.PHONY: format lint build build-release build-docker run debug
build:
+ python3 ./error_gen.py
g++ main.cpp --std=c++20 -g -o ./anthracite
build-release:
diff --git a/src/error_gen.py b/src/error_gen.py
new file mode 100644
index 0000000..31a8d99
--- /dev/null
+++ b/src/error_gen.py
@@ -0,0 +1,75 @@
+# error_gen.py
+# Generates default html error pages for Anthracite
+
+import os
+
+version = "0.1.5"
+
+def generate_error_page(error_code, error_title, error_description):
+ html = f"""
+
{error_title}
+
+
+ {error_code} - {error_title}
+
+ {error_description}
+ Anthracite/{version}
+ This is Open Source Software
+
+
+"""
+ return html
+
+error_codes = {
+ 400: "Bad Request",
+ 401: "Unauthorized",
+ 402: "Payment Required",
+ 403: "Forbidden",
+ 404: "Not Found",
+ 405: "Method Not Allowed",
+ 406: "Not Acceptable",
+ 407: "Proxy Authentication Required",
+ 408: "Request Timeout",
+ 409: "Conflict",
+ 410: "Gone",
+ 411: "Length Required",
+ 412: "Precondition Failed",
+ 413: "Payload Too Large",
+ 414: "URI Too Long",
+ 415: "Unsupported Media Type",
+ 416: "Range Not Satisfiable",
+ 417: "Expectation Failed",
+ 418: "I'm a teapot",
+ 421: "Misdirected Request",
+ 422: "Unprocessable Entity",
+ 423: "Locked",
+ 424: "Failed Dependency",
+ 425: "Too Early",
+ 426: "Upgrade Required",
+ 428: "Precondition Required",
+ 429: "Too Many Requests",
+ 431: "Request Header Fields Too Large",
+ 451: "Unavailable For Legal Reasons",
+ 500: "Internal Server Error",
+ 501: "Not Implemented",
+ 502: "Bad Gateway",
+ 503: "Service Unavailable",
+ 504: "Gateway Timeout",
+ 505: "HTTP Version Not Supported",
+ 506: "Variant Also Negotiates",
+ 507: "Insufficient Storage",
+ 508: "Loop Detected",
+ 510: "Not Extended",
+ 511: "Network Authentication Required"
+}
+
+
+error_dir = './error_pages'
+os.makedirs(error_dir, exist_ok=True)
+
+for code, title in error_codes.items():
+ error_description = error_codes[code]
+ error_page = generate_error_page(code, title, error_description)
+ file_path = os.path.join(error_dir, f"{code}.html")
+ with open(file_path, "w") as file:
+ file.write(error_page)
diff --git a/src/error_pages/404.html b/src/error_pages/404.html
index ce0c9eb..1424c4b 100644
--- a/src/error_pages/404.html
+++ b/src/error_pages/404.html
@@ -1,12 +1,12 @@
Not Found
-
404 - Not Found
- Anthracite/0.0.1
- This is Open Source Software
+ Not Found
+ Anthracite/0.1.5
+ This is Open Source Software
-
+