File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change 2525
2626
2727def configure_static (settings ):
28+ settings ['UI_ROOT' ] = os .path .join (settings ['BASE_DIR' ], 'ui' )
2829 settings ['STATIC_ROOT' ] = os .path .join (settings ['BASE_DIR' ], 'static' )
2930 settings ['MEDIA_ROOT' ] = os .path .join (settings ['BASE_DIR' ], 'media' )
3031
Original file line number Diff line number Diff line change 1+ import os .path
2+
3+ from django .conf import settings
14from django .urls import include , path
5+ from django .views .static import serve
26
37from splinter .core .views import APIErrorView
48
9+
10+ def serve_ui (request , path ):
11+ path = os .path .normpath (path ).lstrip ('/' )
12+ if os .path .isdir (os .path .join (settings .UI_ROOT , path )):
13+ path = os .path .join (path , 'index.html' )
14+
15+ return serve (request , path , document_root = settings .UI_ROOT )
16+
17+
518urlpatterns = [
619 path ('' , include ('splinter.core.health.urls' )),
720 path ('' , include ('splinter.core.openapi.urls' , namespace = 'openapi' )),
1528 path ('api/' , include ('splinter.apps.user.urls' )),
1629]
1730
31+ if not settings .DEBUG :
32+ urlpatterns .extend ([
33+ path ('' , serve_ui , {'path' : '' }),
34+ path ('<path:path>' , serve_ui ),
35+ ])
36+
1837handler404 = APIErrorView .as_view (status = 404 )
1938handler500 = APIErrorView .as_view (status = 500 )
You can’t perform that action at this time.
0 commit comments