[cse491] HW8 Calling FileServer

C. Titus Brown ctb at msu.edu
Sun Nov 1 16:10:54 PST 2009


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



More information about the cse491-fall-2009 mailing list