Improved thing (may be usefull... later)

This commit is contained in:
Thomas FORGIONE 2015-04-13 12:06:27 +02:00
parent bdb975e2f0
commit e16e971a87
2 changed files with 16 additions and 17 deletions

View File

@ -4,20 +4,4 @@
import sys import sys
from webtools import Web from webtools import Web
def main(): Web.render('index.html')
print('Content-type: text/html')
print()
page = Web.Element(Web.ROOT_DIR + 'templates/page.html')
head = Web.Element(Web.ROOT_DIR + 'templates/head.html')
body = Web.Element(Web.ROOT_DIR + 'templates/body.html')
content = Web.Element('index.html')
page.add_child(head)
page.add_child(body)
body.add_child(content)
page.print()
if __name__ == '__main__':
main()

View File

@ -44,3 +44,18 @@ class Element:
for i in self.children: for i in self.children:
i.print(format) i.print(format)
self.close(format) self.close(format)
def render(filename):
print('Content-type: text/html')
print()
page = Element(ROOT_DIR + 'templates/page.html')
head = Element(ROOT_DIR + 'templates/head.html')
body = Element(ROOT_DIR + 'templates/body.html')
content = Element(filename)
page.add_child(head)
page.add_child(body)
body.add_child(content)
page.print()