Improved thing (may be usefull... later)
This commit is contained in:
		
							parent
							
								
									bdb975e2f0
								
							
						
					
					
						commit
						e16e971a87
					
				
							
								
								
									
										18
									
								
								index.py
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								index.py
									
									
									
									
									
								
							| @ -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() |  | ||||||
|  | |||||||
| @ -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() | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user