Coverage for /home/runner/work/viur-core/viur-core/viur/src/viur/core/modules/site.py: 0%
14 statements
« prev ^ index » next coverage.py v7.6.10, created at 2025-02-07 19:28 +0000
« prev ^ index » next coverage.py v7.6.10, created at 2025-02-07 19:28 +0000
1from viur.core import Module, errors
2from viur.core.decorators import exposed
5class Site(Module):
6 """
7 The Site module simply serves static templates without a module-binding stored in html/sites.
9 It is normally imported as `s` module in modern ViUR projects, to serve pages under short URL.
10 Therefore, a template `html/sites/imprint.html` can be accessed via `/s/imprint` by default.
11 """
13 adminInfo = None
15 @exposed
16 def index(self, template="index", *arg, **kwargs):
17 if ".." in template or "/" in template:
18 return
20 try:
21 template = self.render.getEnv().get_template(self.render.getTemplateFileName("sites/" + template))
22 except:
23 raise errors.NotFound()
25 return template.render()
28Site.html = True