Created
December 25, 2012 04:34
-
-
Save wolf0403/4371628 to your computer and use it in GitHub Desktop.
Test web.py script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import web | |
import sys, time, os | |
### URL Routing | |
urls = ( | |
'(.*)', 'fallback', | |
); | |
class fallback (object): | |
def __init__(self): | |
pass | |
def GET(self, *rest): | |
#time.sleep (0.1) | |
web.header ('Content-Type', 'text/plain') | |
return 'web.py sleep(0.1)' + str(rest) | |
def main(): | |
app = web.application (urls, globals()) | |
web.wsgi.runwsgi = lambda func, addr=None: web.wsgi.runfcgi(func, addr) | |
app.run() | |
if __name__ == '__main__': | |
if len(sys.argv) > 1: | |
port = 8001 | |
try: port = int (sys.argv[1]) | |
except ValueError as e: | |
pass | |
cmd = 'spawn-fcgi -F 2 -d . -p %d -P fcgi.pid -- %s' % ( port, sys.argv[0] ) | |
print cmd | |
os.system (cmd) | |
else: | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment