[CentralOH] web.py

Greg Singer gacsinger at gmail.com
Tue Oct 21 16:01:53 CEST 2008


I think the only solution (besides changing httpserver.py) is
something like the below, which I haven't tested but I think should
work:

url = (
  "/data/(.*)",  "StaticContent"
)

class StaticContent:
  def GET(self, fname):
    try:
      i = open("static/" + fname)
      print i.read()
    except IOError:
      web.notfound()

On Tue, Oct 21, 2008 at 9:50 AM, Mark Erbaugh <mark at microenh.com> wrote:
> I'm using the web server built in to web.py. In this particular
> application, it may be all that is needed as it is low-volume, in-house
> and limited use.
>
> web.py has the ability to statically serve binary files from a
> directory /static/. The client application expects binary files to be
> served from a directory /data/.  Is there any way to have web.py treat
> requests for files from /data/ like it does for /static/?
>
> I found the code that does this (it's in httpserver.py) and modified it
> to work in this case, but I dislike monkeying with "library" code so I'm
> wondering if there is a better way?
>
> Thanks,
> Mark
>
> _______________________________________________
> CentralOH mailing list
> CentralOH at python.org
> http://mail.python.org/mailman/listinfo/centraloh
>


More information about the CentralOH mailing list