UWPCE-PythonCert/training.python_web — pull request #40 by sridhar1982 (2014-01-19 01:18:48+00:00)
Title: assignment -02 submission

This is a great assignment. I did not first understand the tasks.txt, but after discussing with you on saturday,
I got it done in less than 1 h. In the resolve_uri function, I need to hard code "text/plain", in order to make the test pass. Here is my resole_uri method.
def resolve_uri(uri):
relv_uri=uri.lstrip('/')
base='webroot'
path = os.path.join(base,relv_uri)

if os.path.exists(path):
if os.path.isdir(path):
contents=os.listdir(path)
body="/n".join(contents)
elif os.path.isfile(path):
try:
body=open(path,'rb').read()
except :
raise IOError
else:
raise ValueError

mimetype=mimetypes.guess_type(path)[0]
mimetype="text/plain" if not mimetype else mimetype
return body,mimetype