forked from ngerakines/commitment
-
Notifications
You must be signed in to change notification settings - Fork 1
/
commit.py
42 lines (35 loc) · 1.01 KB
/
commit.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
import os
import random
import tornado.httpserver
import tornado.ioloop
import tornado.web
names = ['Nick', 'Steve', 'Andy', 'Qi', 'Fanny', 'Sarah', 'Cord', 'Todd', 'Chris', 'Pasha', 'Gabe', 'Tony', 'Jason', 'Randal', 'Ali', 'Kim', 'Rainer']
def randline():
text = 'commit_messages.txt'
if not os.path.exists(text):
return "Shit ..."
f = file(text, 'rb')
for i,j in enumerate(f):
if random.randint(0,i) == i:
line = j
f.close()
return line
def randname():
for i,j in enumerate(names):
if random.randint(0, i) == i:
line = j
return line
class MainHandler(tornado.web.RequestHandler):
def get(self):
line = randline().replace("XNAMEX", randname())
self.render("index.html", message = line)
settings = {
"static_path": os.path.join(os.path.dirname(__file__), "static"),
}
application = tornado.web.Application([
(r"/", MainHandler),
], **settings)
if __name__ == "__main__":
http_server = tornado.httpserver.HTTPServer(application)
http_server.listen(80)
tornado.ioloop.IOLoop.instance().start()