Skip to content
This repository was archived by the owner on Sep 22, 2020. It is now read-only.

Commit b245aef

Browse files
author
Bernhard Grünewaldt
committed
html error pages
1 parent 36ef3ac commit b245aef

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

cs_proxy/proxy.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import sys, os
22
import argparse
33
import colorama
4-
from bottle import route, request, response, run, hook, abort, redirect, error, install, auth_basic
4+
from bottle import route, request, response, run, hook, abort, redirect, error, install, auth_basic, template
55
import simplejson as json
66
import random
77
import logging
@@ -122,6 +122,18 @@ def proxy_trough_helper(url):
122122
return proxy_response
123123

124124

125+
def render_error_page(error):
126+
return template(('<html>'
127+
'<head><title>Error | Auth Basic GitHub Pages Proxy by comSysto</title></head>'
128+
'<body>'
129+
'<div style="">',
130+
'<img src="https://comsysto.github.io/github-pages-basic-auth-proxy/public/logo-small.png">',
131+
'<h1>Error {{error.code}}</h1>',
132+
'{{error.body}}'
133+
'</div>',
134+
'</body></html>'
135+
) , error=error)
136+
125137
#
126138
# BOTTLE APP
127139
#
@@ -132,11 +144,11 @@ def run_proxy(args):
132144
#
133145
@error(401)
134146
def error404(error):
135-
return json.dumps({ 'error': error.body })
147+
return render_error_page(error)
136148

137149
@error(500)
138150
def error500(error):
139-
return json.dumps({ 'error': error.body })
151+
return render_error_page(error)
140152

141153
#
142154
# SPECIAL ENDPOINTS

0 commit comments

Comments
 (0)