@@ -38,9 +38,12 @@ def NavBar(dir_path, info=True, active=''):
3838
3939@app .get ('/split/{category}/{project}' )
4040def split_view (category : str , project : str ):
41- dir_path = Path ('examples' )/ category / project
42- code_text = (dir_path / 'app.py' ).read_text ().strip ()
43- info = (dir_path / 'info.md' ).exists ()
41+ try :
42+ dir_path = Path ('examples' )/ category / project
43+ code_text = (dir_path / 'app.py' ).read_text ().strip ()
44+ info = (dir_path / 'info.md' ).exists ()
45+ except :
46+ return Response (status_code = 404 )
4447 return (
4548 NavBar (dir_path , info = info , active = 'split' ),
4649 Title (f"{ dir_path .name } - Split View" ),
@@ -50,15 +53,21 @@ def split_view(category: str, project: str):
5053
5154@app .get ('/code/{category}/{project}' )
5255def application_code (category :str , project :str ):
53- dir_path = Path ('examples' )/ category / project
54- code_text = (dir_path / 'app.py' ).read_text ().strip ()
55- info = (dir_path / 'info.md' ).exists ()
56+ try :
57+ dir_path = Path ('examples' )/ category / project
58+ code_text = (dir_path / 'app.py' ).read_text ().strip ()
59+ info = (dir_path / 'info.md' ).exists ()
60+ except :
61+ return Response (status_code = 404 )
5662 return (NavBar (dir_path , info = info , active = 'code' ), Title (f"{ dir_path .name } - Code" ), Container (Pre (Code (code_text , cls = 'language-python' ))))
5763
5864@app .get ('/info/{category}/{project}' )
5965def application_info (category :str , project :str ):
60- dir_path = Path ('examples' )/ category / project
61- md_text = (dir_path / 'info.md' ).read_text ()
66+ try :
67+ dir_path = Path ('examples' )/ category / project
68+ md_text = (dir_path / 'info.md' ).read_text ()
69+ except :
70+ return Response (status_code = 404 )
6271 return (NavBar (dir_path , info = True , active = 'info' ), Title (f"{ dir_path .name } - Info" ), Container (render_md (md_text )))
6372
6473def ImageCard (dir_path ):
0 commit comments