diff --git a/core/views_expo.py b/core/views_expo.py index fb4c06c..49f8bc7 100644 --- a/core/views_expo.py +++ b/core/views_expo.py @@ -9,6 +9,7 @@ from django.http import HttpResponse, HttpResponseRedirect, Http404 from django.urls import reverse, resolve from django.template import Context, loader from django.views.decorators.csrf import ensure_csrf_cookie +from django.contrib import admin import django.forms as forms @@ -55,93 +56,96 @@ def expofilesdir(request, dirpath, filepath): fileitems.append((Path(urlpath) / f.parts[-1], str(f.parts[-1]), getmimetype(f))) return render(request, 'dirdisplay.html', { 'filepath': urlpath, 'fileitems':fileitems, 'diritems': diritems,'settings': settings }) +def expowebpage(request, expowebpath, path): + '''Adds memnus and serves an HTML page + ''' + if not Path(expowebpath / path).is_file(): + return render(request, 'pagenotfound.html', {'path': path}) + + with open(os.path.normpath(expowebpath / path), "rb") as o: + html = o.read() + + m = re.search(rb'(.*)<\s*head([^>]*)>(.*)<\s*/head\s*>(.*)<\s*body([^>]*)>(.*)<\s*/body\s*>(.*)', html, re.DOTALL + re.IGNORECASE) + if m: + preheader, headerattrs, head, postheader, bodyattrs, body, postbody = m.groups() + else: + return HttpResponse(html + "HTML Parsing failure: Page could not be split into header and body: failed in expowebpage in views_expo.py") + m = re.search(rb"
i.e. without the final '/' +{% include "menu.html" %} +{% endblock %}