open and read file into a variable in django
def get(self, request, *args, **kwargs):
if request.user.is_superuser:
report_path = os.path.join(settings.BASE_DIR, 'access_log', 'report.html')
with open(report_path, 'r') as f:
html = f.read()
return HttpResponse(html)
else:
raise Http404(_("Benutzer ist nicht berechtigt!"))
return static html page in django
as the example shown before, return static html as string to HttpResponse.