-
Notifications
You must be signed in to change notification settings - Fork 0
/
hello.py
executable file
·70 lines (66 loc) · 2.04 KB
/
hello.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/python
import cherrypy, spynot
#cherrypy.engine.autoreload.unsubscribe()
class SpyNot():
@cherrypy.expose
def index(self):
return """
<!doctype html>
<html>
<head>
<title>Don't blink.</title>
<link href="http://findicons.com/icon/download/146056/the_tardis/32/ico?id=317407" rel="icon" type="image/x-icon" />
<style>
html {background:url(http://i.imgur.com/P9gvk3Hh.jpg) no-repeat center center fixed; background-size:cover}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
</head>
<body>
<article>
</article>
<script>
images = ["http://i.imgur.com/P9gvk3Hh.jpg", "http://i.imgur.com/ZaGrJMRh.jpg", "http://i.imgur.com/r9PgjFZh.jpg", "http://i.imgur.com/chfxpVph.jpg", "http://i.imgur.com/fANm8IGh.jpg", "http://i.imgur.com/HmRD9XIh.jpg"]
for (i = 0; i < images.length; i++) new Image().src = images[i]
function updateBackground(url)
{
$("html").css('background', 'url(' + url + ') no-repeat center center fixed');
$("html").css('background-size', 'cover');
}
$(document).ready(function()
{
setTimeout(function(){
updateBackground(images[1]);
document.title = "Blink and you're dead.";
}, 3000);
setTimeout(function(){
updateBackground(images[2]);
document.title = "They are fast. Faster than you can believe.";
}, 13000);
setTimeout(function(){
updateBackground(images[3]);
document.title = "Don't turn your back. Don't look away.";
}, 15000);
setTimeout(function(){
updateBackground(images[4]);
document.title = "And don't blink.";
}, 30000);
setTimeout(function(){
updateBackground(images[5]);
document.title = "Good luck.";
}, 35000);
});
</script>
</body>
</html>"""
@cherrypy.expose
def api(self, json=None):
cherrypy.response.headers['Content-Type'] = 'application/json'
if json is None and cherrypy.request.method == "POST":
body = cherrypy.request.body.read()
print body
return spynot.api(body)
else:
print json
return spynot.api(json)
cherrypy.config.update({'server.socket_host': '127.0.0.1', 'server.socket_port': 9999, })
cherrypy.quickstart(SpyNot())