Spaces:
Sleeping
Sleeping
import posixpath | |
from pathlib import Path | |
from django.utils._os import safe_join | |
from django.views.static import serve as static_serve | |
from django.http import HttpResponse | |
from django.shortcuts import render | |
from django.template import loader | |
def serve_react(request, path, document_root=None): | |
path = posixpath.normpath(path).lstrip("/") | |
fullpath = Path(safe_join(document_root, path)) | |
print(fullpath, document_root) | |
if fullpath.is_file(): | |
return static_serve(request, path, document_root) | |
else: | |
# return static_serve(request, "index.html", document_root) | |
# send index.html as template | |
return render(request, 'index.html') | |
def index(request): | |
return render(request, 'index.html') | |