Spaces:
Sleeping
Sleeping
File size: 764 Bytes
2e53f8d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
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')
|