Hello,
I'm having quite a bit of trouble coaxing the built in wsgi server in
webpy to host static files while daemonized. My goal here is to have a
local (daemonized) webserver I can dev on while being able to push to
my production server running mod_wsgi. So far webpy has been great in
that capacity, however now that I have my "hello world" working the
way I want locally and remotely, I can't serve static files.
I'm using this technique to daemonize:
http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/
According to webpy, all I have to do is make a directory called
'static' in the same spot as my application code, and it will serve
them statically. When I so this and run the code below, I get 404
pages for my static files. I suspect the problem might be something to
do with threading and/or me not subclassing correctly, but I have not
been able to figure it out.
The code I'm trying to run is this:
#!/usr/bin/env python
import sys, time, os
import web
from daemon import Daemon
urls = (
'/', 'hello'
)
class hello:
def GET(self):
return "Hello, world!"
class server(Daemon):
def run(self):
app = web.application(urls, globals(), autoreload=True)
app.internalerror = web.debugerror
app.run()
if __name__ == "__main__":
if len(sys.argv) == 2:
daemon = server('/home/ld/ABS/server.pid') # make the pidfile
appear here
if 'start' == sys.argv[1]:
print "starting local webserver"
# need to overwrite argv[1] so webpy gets the right port
number
sys.argv[1] = '8080'
daemon.start()
elif 'stop' == sys.argv[1]:
print "stopping local webserver"
daemon.stop()
elif 'restart' == sys.argv[1]:
print "restarting local webserver"
daemon.restart()
else:
print "Unknown command"
sys.exit(2)
sys.exit(0)
else:
print "usage: %s start|stop|restart" % sys.argv[0]
sys.exit(2)
# mod_wsgi will catch this instance of the wsgi application
app = web.application(urls, globals(), autoreload=False)
application = app.wsgifunc()
Thanks for your help!