Skip to content

Commit d8d9366

Browse files
authored
Merge pull request #20 from cmu-delphi/add-main-page-env-var
Updated the `STATIC_URL` and `MEDIA_URL` to include the `MAIN_PAGE` variable, which allows for dynamic URL generation based on the environment variable value
2 parents 7331838 + 7802582 commit d8d9366

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/signal_documentation/settings.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,21 +169,19 @@
169169

170170
LOCALE_PATHS: list[str] = [os.path.join(BASE_DIR, 'locale')]
171171

172+
MAIN_PAGE = os.environ.get('MAIN_PAGE', '')
172173

173174
# Static files (CSS, JavaScript, Images)
174175
# https://docs.djangoproject.com/en/4.2/howto/static-files/
175176

176-
STATIC_URL: str = '/static/'
177+
STATIC_URL: str = f'{MAIN_PAGE}/static/'
177178
STATICFILES_DIRS: tuple[str] = (os.path.join(BASE_DIR, 'assets'),)
178179
STATIC_ROOT: str = os.path.join(BASE_DIR, 'staticfiles')
179180

180-
MEDIA_URL: str = '/media/'
181+
MEDIA_URL: str = f'{MAIN_PAGE}/media/'
181182
MEDIA_ROOT: str = os.path.join(BASE_DIR, 'media')
182183

183184

184-
MAIN_PAGE = os.environ.get('MAIN_PAGE', '')
185-
186-
187185
# Default primary key field type
188186
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
189187

src/signal_documentation/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
urlpatterns: list[URLResolver] = [
3939
path('admin/', admin.site.urls),
4040
path('__debug__/', include('debug_toolbar.urls')),
41-
path(settings.MAIN_PAGE, include('signals.urls')),
41+
path(f'{settings.MAIN_PAGE}/', include('signals.urls')),
4242
]
4343

4444
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) # type: ignore

0 commit comments

Comments
 (0)