[cse491] HW8 Calling FileServer

C. Titus Brown ctb at msu.edu
Mon Nov 2 17:21:27 PST 2009


On Mon, Nov 02, 2009 at 07:47:43PM -0500, Andrew Kos wrote:
> Don't you still have to pass in those two variables even if you make it a
> callable?

app = FileServer('/some/path')
iterable = app(environ, start_response)

--titus

> On Sun, Nov 1, 2009 at 7:10 PM, C. Titus Brown <ctb at msu.edu> wrote:
> 
> > On Sun, Nov 01, 2009 at 06:36:41PM -0500, Andrew Kos wrote:
> > > Good Evening,
> > > In the homework guidelines, it says that we should be able to call
> > > FileServer as:
> > >
> > > import apps app = FileServer('/some/path')
> > >
> > > but with the process_form app we had to be able to pass a start_response
> > and
> > > environ as arguments. Is there a different way that we're supposed to
> > > implement FileServer, or am I just missing something?
> >
> > Hi Andrew,
> >
> > first, the code example above is messed up -- a formatting error when
> > converting the .txt to .html... I've fixed
> >
> > http://ged.msu.edu/courses/2009-fall-cse-491/cse491-2009-hw8.html
> >
> > The real code must look something like this,
> >
> >        from apps import FileServer
> >        app = FileServer('/some/path')
> >
> > OK, so on to the actual question -- here, 'app' must be WSGI compliant,
> > which means that *when you call the object as if it were a function*,
> > it takes start_response and environ.  There are many ways to construct
> > such an object, and the above code is telling you that *this* object
> > must be constructed as
> >
> >        app = FileServer('/some/path')
> >
> > I think the most natural way to implement FileServer is as a class, 2nd
> > example under "Callables in WSGI", here:
> >
> >        http://ged.msu.edu/courses/2009-fall-cse-491/cse491-2009-lab7.html
> >
> > although there are other ways to make it work.  The whole set of lab notes
> > through that section might be worth reading...
> >
> > cheers,
> > --titus
> > --
> > C. Titus Brown, ctb at msu.edu
> >

-- 
C. Titus Brown, ctb at msu.edu



More information about the cse491-fall-2009 mailing list