diff options
author | Kristian Lyngstol <kly@kly.no> | 2016-11-07 21:47:37 +0100 |
---|---|---|
committer | Kristian Lyngstol <kly@kly.no> | 2016-11-07 21:47:37 +0100 |
commit | c9bdd40a9f90c9f5205ba058d6bc5ab1443dfee4 (patch) | |
tree | 50927cb5610df6fb1f0d6162efae91f2feac6d60 /templating/templating.py | |
parent | f0ba03a2319f1c2ac9346494dc03696684722d4e (diff) |
Templating: Add variable-support and provide demo
This SHOULD resolve everything needed for FAP from a templating
perspective.
Diffstat (limited to 'templating/templating.py')
-rwxr-xr-x | templating/templating.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/templating/templating.py b/templating/templating.py index 5144b89..57d81b1 100755 --- a/templating/templating.py +++ b/templating/templating.py @@ -24,9 +24,20 @@ class MyHandler(http.server.BaseHTTPRequestHandler): def do_GET(self): print (self.path[1:]) updateData() + url = self.path[1:] + options = dict() + if url.find("?") != -1: + (url, tmpoptions) = url.split("?") + print (tmpoptions) + tmptuples = tmpoptions.split("&") + print (tmptuples) + for a in tmptuples: + (x,y) = a.split("=") + options[x] = y + try: - template = env.get_template(self.path[1:]) - body = template.render(objects=objects).encode('UTF-8') + template = env.get_template(url) + body = template.render(objects=objects, options=options).encode('UTF-8') self.send_response(200) except: body = "baaad\n".encode('UTF-8') |