11import sys , os
22import argparse
33import colorama
4- from bottle import route , request , response , run , hook , abort , redirect , error , install , auth_basic , template
4+ from bottle import route , view , request , response , run , hook , abort , redirect , error , install , auth_basic , template
55import simplejson as json
66import random
77import logging
@@ -56,6 +56,29 @@ def main():
5656auth_type = 0
5757jwt_secret = "%032x" % random .getrandbits (128 )
5858
59+ #
60+ # TEMPLATES
61+ #
62+ default_header_tpl = """<html>
63+ <head><title>{{headline}} | Auth Basic GitHub Pages Proxy by comSysto</title></head>
64+ <body>
65+ <div style="font-family:sans-serif;margin:auto;padding:50px 100px 50px 100px;">
66+ <div style="width:100%;background:#1e9dcc">
67+ <img src="https://comsysto.github.io/github-pages-basic-auth-proxy/public/logo-small.png">
68+ </div>
69+ <h1>{{headline}}</h1>"""
70+
71+ default_footer_tpl = """</div>
72+ </body></html>"""
73+
74+ default_tpl = default_header_tpl + '{{body}}' + default_footer_tpl
75+
76+ healthcheck_tpl = default_header_tpl + """
77+ <span style="background:#99d100;padding:20px;color:#fff">✓ Proxy is running fine.</span>""" + default_footer_tpl
78+
79+ install_success_tpl = default_header_tpl + """
80+ <span style="background:#99d100;padding:20px;color:#fff">✓ Installation done.</span>""" + default_footer_tpl
81+
5982#
6083# HELPERS
6184#
@@ -123,16 +146,7 @@ def proxy_trough_helper(url):
123146
124147
125148def 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 )
149+ return template (default_tpl , headline = 'Error ' + error .status , body = error .body )
136150
137151#
138152# BOTTLE APP
@@ -155,11 +169,11 @@ def error500(error):
155169 #
156170 @route ('/health' )
157171 def hello ():
158- return 'ok'
172+ return template ( healthcheck_tpl , headline = 'Healthcheck' )
159173
160174 @route ('/install-success' )
161175 def hello ():
162- return 'The Auth Basic GitHub Pages Proxy was installed successfully.'
176+ return template ( install_success_tpl , headline = 'Installation Success' )
163177
164178 #
165179 # make args available in auth callback
0 commit comments