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

Commit 21ae6ac

Browse files
added check to install-success page if gh-page returns http 200
1 parent 6a4147b commit 21ae6ac

1 file changed

Lines changed: 18 additions & 7 deletions

File tree

cs_proxy/proxy.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,20 @@ def main():
7474
default_tpl = default_header_tpl + '{{body}}' + default_footer_tpl
7575

7676
healthcheck_tpl = default_header_tpl + """
77-
<span style="background:#99d100;padding:20px;color:#fff">&#10003; Proxy is running fine.</span>""" + default_footer_tpl
77+
<div style="background:#99d100;padding:20px;color:#fff">&#10003; Proxy is running fine.</div>""" + default_footer_tpl
7878

7979
error_tpl = default_header_tpl + """
80-
<span style="background:#bf1101;padding:20px;color:#fff">&#10008; {{error.body}}</span>""" + default_footer_tpl
80+
<div style="background:#bf1101;padding:20px;color:#fff">&#10008; {{error.body}}</div>""" + default_footer_tpl
8181

8282
install_success_tpl = default_header_tpl + """
83-
<span style="background:#99d100;padding:20px;color:#fff">&#10003; Installation done.</span>""" + default_footer_tpl
83+
<div style="background:#99d100;padding:20px;color:#fff">&#10003; Installation done.</div>
84+
<br><br>
85+
%if remote_page_call_status_code != 200:
86+
<div style="background:#bf1101;padding:20px;color:#fff">&#10008; Error calling the gh-pages page (Status {{remote_page_call_status_code}}). Please check the env vars (obfuscator, repositoryOwner and repositoryName) and place a index.html inside the obfuscator dir.</div>
87+
%else:
88+
<div style="background:#99d100;padding:20px;color:#fff">&#10003; Success calling the gh-pages page.</div>
89+
%end
90+
""" + default_footer_tpl
8491

8592
#
8693
# HELPERS
@@ -142,9 +149,12 @@ def normalize_proxy_url(url):
142149
def proxy_trough_helper(url):
143150
print ('PROXY-GET: {0}'.format(url))
144151
proxy_response = requests.get(url)
145-
response.set_header('Last-Modified', proxy_response.headers['Last-Modified'])
146-
response.set_header('Content-Type', proxy_response.headers['Content-Type'])
147-
response.set_header('Expires', proxy_response.headers['Expires'])
152+
if hasattr(proxy_response.headers, 'Last-Modified'):
153+
response.set_header('Last-Modified', proxy_response.headers['Last-Modified'])
154+
if hasattr(proxy_response.headers, 'Content-Type'):
155+
response.set_header('Content-Type', proxy_response.headers['Content-Type'])
156+
if hasattr(proxy_response.headers, 'Expires'):
157+
response.set_header('Expires', proxy_response.headers['Expires'])
148158
return proxy_response
149159

150160

@@ -173,7 +183,8 @@ def hello():
173183

174184
@route('/install-success')
175185
def hello():
176-
return template(install_success_tpl, headline='Installation Success')
186+
remote_page_call_status_code = proxy_trough_helper('https://{0}.github.io/{1}/{2}/{3}'.format(args.owner, args.repository, args.obfuscator, '/')).status_code
187+
return template(install_success_tpl, headline='Installation Success', remote_page_call_status_code=remote_page_call_status_code)
177188

178189
#
179190
# make args available in auth callback

0 commit comments

Comments
 (0)