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

Commit 3a7ff41

Browse files
author
bg
committed
basic html pages
1 parent b245aef commit 3a7ff41

1 file changed

Lines changed: 27 additions & 13 deletions

File tree

cs_proxy/proxy.py

Lines changed: 27 additions & 13 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, template
4+
from bottle import route, view, request, response, run, hook, abort, redirect, error, install, auth_basic, template
55
import simplejson as json
66
import random
77
import logging
@@ -56,6 +56,29 @@ def main():
5656
auth_type = 0
5757
jwt_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">&#10003; 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">&#10003; Installation done.</span>""" + default_footer_tpl
81+
5982
#
6083
# HELPERS
6184
#
@@ -123,16 +146,7 @@ def proxy_trough_helper(url):
123146

124147

125148
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)
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

Comments
 (0)