Skip to content

Commit

Permalink
mostly working
Browse files Browse the repository at this point in the history
  • Loading branch information
al3x committed May 20, 2008
1 parent 992d351 commit e2e8147
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 42 deletions.
50 changes: 47 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,60 @@
#!/usr/bin/env python

import web
import web, cgi, re
from google.appengine.api import urlfetch

urls = (
'/', 'index'
'/', 'index',
'/(.*)', 'check'
)

render = web.template.render('templates/')

HTTPRE = re.compile('http:\/\/')
DOWNRE = re.compile('downforeveryoneorjustme\.com')

def cleanurl(domain):
domain = cgi.escape(domain)
domain.encode("utf-8")

if HTTPRE.match(domain):
domain = 'http://' + domain

return domain

class index:
def GET(self):
return render.index()
title = 'Down for everyone or just me?'
output = render.index()
return render.layout(output, title)

class check:
def GET(self, domain):
domain = cleanurl(domain)

if DOWNRE.match(domain):
title = "It's just you."
output = render.hurr()
return render.layout(output, title)

try:
response = urlfetch.fetch(domain, method='HEAD')
except:
title = "Huh?"
output = render.error()
return render.layout(output, title)
else:
status = response.status_code

if (status == 200) or (status == 301) or (status == 302):
title = "It's just you."
output = render.up(domain)
else:
title = "It's not just you!"
output = render.down(domain)

return render.layout(output, title)


app = web.application(urls, globals())
main = app.cgirun()
13 changes: 13 additions & 0 deletions templates/down.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
$def with (domain)
It's not just you! <a href="http://$domain" class="domain">$domain</a> looks down from here.
<p><a href="/">Check another site?</a></p>
<script type="text/javascript">
<!--
google_ad_client = "pub-7099521943661584";
/* 468x60, created 3/13/08 */
google_ad_slot = "0281650900";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
12 changes: 12 additions & 0 deletions templates/error.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Huh? That doesn't look like a site on the interwho.
<p><a href="/">Try again?</a></p>
<script type="text/javascript">
<!--
google_ad_client = "pub-7099521943661584";
/* 468x60, created 3/13/08 */
google_ad_slot = "0281650900";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
12 changes: 12 additions & 0 deletions templates/hurr.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
If you can see this page and still think we're down, it's just you.
<p><a href="/">Check another site?</a></p>
<script type="text/javascript">
<!--
google_ad_client = "pub-7099521943661584";
/* 468x60, created 3/13/08 */
google_ad_slot = "0281650900";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
46 changes: 7 additions & 39 deletions templates/index.html
Original file line number Diff line number Diff line change
@@ -1,39 +1,7 @@
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<link rel="shortcut icon" href="http://static.al3x.net/down_favicon.ico" type="image/x-icon" />
<!--tipjoy:al3x-->
<title>Down for everyone or just me?</title>
<style type="text/css">
body{background-color:#fff;color:#333;font-family:Arial,Verdana,sans-serif;font-size:62.5%;margin:10% 5% 0 5%;text-align:center;}
a,a:visited,a:active{color:#0080ff;text-decoration:underline;}
a:hover{text-decoration:none;}
input[type=text]{border:1px solid #ccc;color:#ccc;font-size:1em;padding:4px 6px 4px 6px;}
.domain{font-weight:bold;}
#container{clear:both;font-size:3em;margin:auto;}
#domain_input{width:250px;}
</style>
<script type="text/javascript">
function clearDomainInput(e) {
if (e.cleared) { return; }
e.cleared = true;
e.value = '';
e.style.color = '#000';
}
</script>
</head>
<body>
<div id="container">
Back soon.
</div>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-853305-3");
pageTracker._initData();
pageTracker._trackPageview();
</script>
</body>
</html>
<form method="get" name="downform" action="/q" onsubmit="return formSubmit()">
Is
<input type="text" name="domain" id="domain_input" value="google.com" onclick="clearDomainInput(this);" />
down for everyone
<a href="#" onclick="formSubmit();">or just me?</a>
<input type="submit" style="display: none;" />
</form>
46 changes: 46 additions & 0 deletions templates/layout.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
$def with (content_for_layout, title)
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<link rel="shortcut icon" href="http://static.al3x.net/down_favicon.ico" type="image/x-icon" />
<!--tipjoy:al3x-->
<title>$title</title>
<style type="text/css">
body{background-color:#fff;color:#333;font-family:Arial,Verdana,sans-serif;font-size:62.5%;margin:10% 5% 0 5%;text-align:center;}
a,a:visited,a:active{color:#0080ff;text-decoration:underline;}
a:hover{text-decoration:none;}
input[type=text]{border:1px solid #ccc;color:#ccc;font-size:1em;padding:4px 6px 4px 6px;}
.domain{font-weight:bold;}
#container{clear:both;font-size:3em;margin:auto;}
#domain_input{width:250px;}
</style>
<script type="text/javascript">
function clearDomainInput(e) {
if (e.cleared) { return; }
e.cleared = true;
e.value = '';
e.style.color = '#000';
}

function formSubmit() {
domain = document.getElementById('domain_input').value;
window.location = '/' + domain;
return false;
}
</script>
</head>
<body>
<div id="container">
$:content_for_layout
</div>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-853305-3");
pageTracker._initData();
pageTracker._trackPageview();
</script>
</body>
</html>
13 changes: 13 additions & 0 deletions templates/up.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
$def with (domain)
It's just you. <a href="http://$domain" class="domain">$domain</a></span> is up.
<p><a href="/">Check another site?</a></p>
<script type="text/javascript">
<!--
google_ad_client = "pub-7099521943661584";
/* 468x60, created 3/13/08 */
google_ad_slot = "0281650900";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>

0 comments on commit e2e8147

Please sign in to comment.