Serving static files from a web.py + gevent server

320 views
Skip to first unread message

Alexandre Rames

unread,
Apr 13, 2012, 5:57:52 PM4/13/12
to gev...@googlegroups.com, Alexandre Rames
Hello,

I am a beginner with webservers and gevent.

Using gevent with my web.py server prevents it from serving files located in /static, which it normally does by default.
I hacked it by adding a   '/static/(.*)', 'static' path with a class getting the correct files.
Is there a way to keep that automatic? Maybe a parameter when building the WSGI server?

Thanks!

urls = (
  '/', 'index',
  '/static/(.*)', 'static'    # I don't want that
)
class index:
  def GET(self:
    # the rendered index includes    <script type="text/javascript" src="/static/jquery.js"></script>
    return render.index()
class static:
  deg GET(self, name):
    return open('static/%s' % name)

if __name__ == "__main__":
  # That works without the additional static url and class.
  #web.application(urls,globals()).run()
  # That does not work without the 'static' additional code.
  application = web.application(urls, globals()).wsgifunc()
  print 'Serving on 8080...'
  WSGIServer(('localhost', 8080), application).serve_forever()
Reply all
Reply to author
Forward
0 new messages