Skip to content

Instantly share code, notes, and snippets.

@wolf0403
Created December 25, 2012 04:34
Show Gist options
  • Save wolf0403/4371628 to your computer and use it in GitHub Desktop.
Save wolf0403/4371628 to your computer and use it in GitHub Desktop.
Test web.py script
#!/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