-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.py
executable file
·55 lines (40 loc) · 1.45 KB
/
index.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
'''
index.py I shall do nothing but render the interface
'''
import os
import wsgiref.handlers
from google.appengine.ext import webapp
from google.appengine.ext.webapp import template
import web2hunter as WH
class MainHandler(webapp.RequestHandler):
tPath = os.path.join( os.path.dirname (__file__), "templates" )
def get(self):
todo = self.request.get('getname');
if (todo == 'true'):
if (self.request.headers.get('Referer') != None):
# stop others from stealing your bandwidth
#if (self.request.headers.get('Referer').find('web2hunter.appspot.com')!=-1):
# return a possible domain name
possiblename = WH.genName()
while (possiblename == ""):
possiblename = WH.genName()
# lets sanitize the possible name
# for sometime we get the response header for some reason -
# Content-Type: text/html; charset=utf-8 Cache-Control: ... blabla
# well a foo.split()[-1] would help
# food for javascript + sanitization
self.response.out.write (possiblename.split()[-1])
#else:
#self.response.out.write ("nothing for you");
else:
self.response.out.write ("nothing for you");
else:
# render the template
outstr = template.render (
self.tPath + '/index.html', None )
self.response.out.write (outstr)
def main():
application = webapp.WSGIApplication( [('/.*',MainHandler)], debug=True )
wsgiref.handlers.CGIHandler().run(application)
if __name__ == '__main__':
main()