File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ class Things3API():
3535
3636 def on_get (self , url ):
3737 """Handles other GET requests"""
38+ status = 200
3839 filename = self .PATH + url
3940 content_type = 'application/json'
4041 if filename .endswith ('css' ):
@@ -49,9 +50,14 @@ def on_get(self, url):
4950 content_type = 'image/jpeg'
5051 if filename .endswith ('ico' ):
5152 content_type = 'image/x-ico'
52- with open (filename , 'rb' ) as source :
53- data = source .read ()
54- return Response (response = data , content_type = content_type )
53+ try :
54+ with open (filename , 'rb' ) as source :
55+ data = source .read ()
56+ except FileNotFoundError :
57+ data = 'not found'
58+ content_type = 'text'
59+ status = 404
60+ return Response (response = data , content_type = content_type , status = status )
5561
5662 def mode_selector (self ):
5763 """Switch between project and task mode"""
You can’t perform that action at this time.
0 commit comments