diff options
author | Camil Staps | 2016-03-04 18:33:12 +0100 |
---|---|---|
committer | Camil Staps | 2016-03-04 18:33:12 +0100 |
commit | 198db6f0003935e5f900719fa0b848924b8921bb (patch) | |
tree | 783956c7f4ced78e864a0ea7503bf5a63bef7370 /project1/proj1_s4498062/webhttp/resource.py | |
parent | Added framework project 1 (diff) |
Project one until step 8 in the readme
Diffstat (limited to 'project1/proj1_s4498062/webhttp/resource.py')
-rw-r--r-- | project1/proj1_s4498062/webhttp/resource.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/project1/proj1_s4498062/webhttp/resource.py b/project1/proj1_s4498062/webhttp/resource.py index dc20067..cf2b725 100644 --- a/project1/proj1_s4498062/webhttp/resource.py +++ b/project1/proj1_s4498062/webhttp/resource.py @@ -4,7 +4,7 @@ This module contains a handler class for resources. """
import os
-import mimetype
+import mimetypes
import urlparse
@@ -34,8 +34,12 @@ class Resource: self.uri = uri
out = urlparse.urlparse(uri)
self.path = os.path.join("content", out.path.lstrip("/"))
+ if not os.path.exists(self.path):
+ raise FileExistError
if os.path.isdir(self.path):
self.path = os.path.join(self.path, "index.html")
+ if not os.path.exists(self.path):
+ raise FileAccessError
if not os.path.isfile(self.path):
raise FileExistError
if not os.access(self.path, os.R_OK):
|