se agrega frontend en ruta raiz
|
@ -10,18 +10,8 @@ class ApiMiddleware:
|
|||
self.get_response = get_response
|
||||
|
||||
def __call__(self, request):
|
||||
# se omite esta regla en frontend
|
||||
if request.path == '/' or request.path[0:8] == '/assets/':
|
||||
response = self.get_response(request)
|
||||
return response
|
||||
|
||||
# se omite esta regla en admin de django
|
||||
if request.path[0:7] == '/admin/':
|
||||
response = self.get_response(request)
|
||||
return response
|
||||
|
||||
# se omite esta regla en documentacion
|
||||
if request.path[0:6] == '/docs/':
|
||||
# se omite esta regla si no es api
|
||||
if request.path[0:5] != '/api/':
|
||||
response = self.get_response(request)
|
||||
return response
|
||||
|
||||
|
|
After Width: | Height: | Size: 1.3 MiB |
After Width: | Height: | Size: 19 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 32 KiB |
After Width: | Height: | Size: 6.5 KiB |
After Width: | Height: | Size: 36 KiB |
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Gestión de Transporte</title>
|
||||
<script type="module" crossorigin src="/assets/index-fb7fa786.js"></script>
|
||||
<link rel="stylesheet" href="/assets/index-9c8ce59f.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -41,7 +41,7 @@ INSTALLED_APPS = [
|
|||
'rest_framework',
|
||||
'coreapi',
|
||||
'corsheaders',
|
||||
'api'
|
||||
'api',
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
|
@ -61,7 +61,7 @@ ROOT_URLCONF = 'project.urls'
|
|||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [ BASE_DIR / 'dist/' ],
|
||||
'DIRS': [ BASE_DIR / 'dist' ],
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
|
@ -129,9 +129,7 @@ USE_TZ = True
|
|||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/4.2/howto/static-files/
|
||||
|
||||
STATIC_URL = 'assets/'
|
||||
# STATIC_ROOT = '/app/project/dist/assets'
|
||||
# MEDIA_URL = 'assets/'
|
||||
STATIC_URL = 'static/'
|
||||
|
||||
# Default primary key field type
|
||||
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
|
||||
|
@ -147,4 +145,5 @@ CORS_ORIGIN_ALLOW_ALL = False
|
|||
CORS_ORIGIN_WHITELIST = [
|
||||
"http://localhost:3000",
|
||||
"http://transporte.hz.kursor.cl",
|
||||
"http://transporte-backend.hz.kursor.cl",
|
||||
]
|
||||
|
|
|
@ -14,26 +14,23 @@ Including another URLconf
|
|||
1. Import the include() function: from django.urls import include, path
|
||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||
"""
|
||||
from django.conf import settings
|
||||
from django.conf.urls.static import static
|
||||
|
||||
from django.contrib import admin
|
||||
from django.urls import path, include
|
||||
from rest_framework.documentation import include_docs_urls
|
||||
|
||||
from django.template.loader import get_template
|
||||
from django.http import HttpResponse
|
||||
|
||||
def frontend(request):
|
||||
plantilla = get_template('index.html')
|
||||
documento = plantilla.render()
|
||||
return HttpResponse(documento)
|
||||
|
||||
from django.conf import settings
|
||||
from django.conf.urls.static import static
|
||||
from .views import frontend
|
||||
|
||||
urlpatterns = [
|
||||
# path('', frontend),
|
||||
path('admin/', admin.site.urls),
|
||||
# FRONTEND
|
||||
path('', frontend, name='home'),
|
||||
|
||||
# BACKEND
|
||||
path('api/', include('api.urls')),
|
||||
path('admin/', admin.site.urls),
|
||||
path('docs/', include_docs_urls(title = 'API Documentation')),
|
||||
]
|
||||
# + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
|
||||
|
||||
urlpatterns += static('assets/', document_root=f'{settings.BASE_DIR}/dist/assets')
|
||||
urlpatterns += static('avatars/', document_root=f'{settings.BASE_DIR}/dist/avatars')
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
from django.template.loader import get_template
|
||||
from django.http import HttpResponse
|
||||
|
||||
def frontend(request):
|
||||
plantilla = get_template('index.html')
|
||||
documento = plantilla.render()
|
||||
return HttpResponse(documento)
|