Skip to content

Instantly share code, notes, and snippets.

@tejastank
Created September 24, 2012 13:40
Show Gist options
  • Save tejastank/3776005 to your computer and use it in GitHub Desktop.
Save tejastank/3776005 to your computer and use it in GitHub Desktop.
tejastank Apache python code.
import sys
import time
import simplejson as json
import jsontemplate
import itertools
def password(req):
l = itertools.permutations(['v','i','r','t','u','a','l'])
tt = [ "".join(x) for x in list(l)]
print ', '.join(tt)
return ', '.join(tt)
def index(req):
# Following line causes error to be sent to browser
# rather than to log file (great for debug!)
sys.stderr = sys.stdout
#print "Content-type: text/html\n"
#print """
blah1 = """<html>
<head><title>A page from Python</title></head>
<body>
<h4>This page is generated by a Python script!</h4>
The current date and time is """
now = time.gmtime()
displaytime = time.strftime("%A %d %B %Y, %X",now)
#print displaytime,
blah1 += displaytime
#print """
blah1 += """
<hr>
Well House Consultants demonstration
</body>
</html>
"""
return blah1
def read(req):
# can test like http://localhost/python/hacker.py/read
req.content_type = "text/plain"
vals = False
vals = json.dumps(['foo', {'bar': ('baz', None, 1.0, 2)}])
return vals
def render(req):
return jsontemplate.expand('Hello {name}', {'name': 'world'})
def orange(req):
# Following line causes error to be sent to browser
# rather than to log file (great for debug!)
#print "Content-type: text/html\n"
#print """
blah1 = """<html>
<head><title>A page from Python</title></head>
<body>
<h1>Tejas Tank."""+ time.strftime("%A %d %B %Y, %X",time.gmtime())+"""</h1>
</body>
</html>
"""
return blah1
def requesthandler(req):
# test via http://localhost/python/hacker.py/requesthandler
req.content_type = "text/plain"
req.write("Hello World!")
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment