diff --git a/backend/config/__pycache__/settings.cpython-311.pyc b/backend/config/__pycache__/settings.cpython-311.pyc index d78cdfd..3fe699a 100644 Binary files a/backend/config/__pycache__/settings.cpython-311.pyc and b/backend/config/__pycache__/settings.cpython-311.pyc differ diff --git a/backend/config/settings.py b/backend/config/settings.py index bb8434d..6522f56 100644 --- a/backend/config/settings.py +++ b/backend/config/settings.py @@ -76,7 +76,7 @@ ROOT_URLCONF = 'config.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [], + 'DIRS': [BASE_DIR.parent / 'frontend' / 'dist'], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ @@ -151,8 +151,8 @@ STATIC_ROOT = BASE_DIR / 'staticfiles' STATICFILES_DIRS = [ BASE_DIR / 'static', - BASE_DIR / 'assets', - BASE_DIR / 'node_modules', + BASE_DIR.parent / 'frontend' / 'dist', + BASE_DIR.parent / 'frontend' / 'dist' / 'assets', ] # Email @@ -196,4 +196,4 @@ REST_FRAMEWORK = { 'rest_framework.authentication.SessionAuthentication', 'rest_framework.authentication.BasicAuthentication', ], -} +} \ No newline at end of file diff --git a/backend/core/__pycache__/urls.cpython-311.pyc b/backend/core/__pycache__/urls.cpython-311.pyc index 441f01f..0408ddc 100644 Binary files a/backend/core/__pycache__/urls.cpython-311.pyc and b/backend/core/__pycache__/urls.cpython-311.pyc differ diff --git a/backend/core/__pycache__/views.cpython-311.pyc b/backend/core/__pycache__/views.cpython-311.pyc index fe78d0e..3def442 100644 Binary files a/backend/core/__pycache__/views.cpython-311.pyc and b/backend/core/__pycache__/views.cpython-311.pyc differ diff --git a/backend/core/urls.py b/backend/core/urls.py index 2ba184a..03d9457 100644 --- a/backend/core/urls.py +++ b/backend/core/urls.py @@ -1,12 +1,13 @@ -from django.urls import path, include +from django.urls import path, include, re_path from rest_framework.routers import DefaultRouter -from .views import SellerViewSet, ProductViewSet, CategoryViewSet +from .views import SellerViewSet, ProductViewSet, CategoryViewSet, serve_frontend router = DefaultRouter() -router.register(r'categories', CategoryViewSet) -router.register(r'sellers', SellerViewSet) -router.register(r'products', ProductViewSet) +router.register(r'api/categories', CategoryViewSet) +router.register(r'api/sellers', SellerViewSet) +router.register(r'api/products', ProductViewSet) urlpatterns = [ path('', include(router.urls)), -] + re_path(r'^(?!api/|admin/).*$', serve_frontend, name='serve_frontend'), +] \ No newline at end of file diff --git a/backend/core/views.py b/backend/core/views.py index 77ccff4..82262ab 100644 --- a/backend/core/views.py +++ b/backend/core/views.py @@ -1,7 +1,13 @@ +import os +from django.shortcuts import render +from django.conf import settings from rest_framework import viewsets from .models import Seller, Product, Category from .serializers import SellerSerializer, ProductSerializer, CategorySerializer +def serve_frontend(request, path=''): + return render(request, 'index.html') + class CategoryViewSet(viewsets.ModelViewSet): queryset = Category.objects.all() serializer_class = CategorySerializer @@ -12,4 +18,4 @@ class SellerViewSet(viewsets.ModelViewSet): class ProductViewSet(viewsets.ModelViewSet): queryset = Product.objects.all() - serializer_class = ProductSerializer \ No newline at end of file + serializer_class = ProductSerializer