A module that you can use to create HTML pages with Python codeš
First, create the file you want to write next to the utils folder. forexample generate.py then, Enter the following code in your file
from utils.tags import *
from utils.run import *
Then add the following code to your file.
@headTag
@styleTag
def head():
return '''div{color:red}'''
@h1Tag
def header():
return 'hello'
@h2Tag
def aside():
return 'this is a aside'
@divTag
def footer():
return 'this is a my footer'
@divTag
def end():
return '''<h2>i come with pyhtml</h2>
<h3> we in a div!</h3>
'''
@freeTag
def comment():
return '''
<!--check my github for new fuetres!-->
<!--fork me please!-->'''
html_array += [
head(),
header(),
aside(),
footer(),
end(),
comment(),
]
mycode = runHTML()
print(mycode)
buildHTML()
then , open generator.py or yourfilename.py in your directory and Pyhtml.html file is created, open it! result: result html code:
<!--This file generated by Pyhtml--><head><style>div{color:red}</style></head><h1>hello</h1><h2>this is a aside</h2><div>this is a my footer</div><div><h2>i come with pyhtml</h2>
<h3> we in a div!</h3>
</div>
<!--check my github for new fuetres!-->
<!--fork me please!-->
To create a head tag and create a style for your html file, you need to use head and style decorators. just like this(You can write your style in return):
@headTag
@styleTag
def head():
return '''div{color:red}'''
Other tags: (h1tag and ...) to create h tag in your file.
@h1Tag , @h2Tag , @h3Tag, @h4Tag, @h5Tag
(divtag) to create div tag in your file.
@divTag
(freetag) to create your custom code in html file.
@freeTag
def comment():
return '''
<!--check my github for new fuetres!-->
<!--fork me please!-->'''
what is html_array?You need to put your defs in html_array to set up your html screen. just like this:
html_array += [
head(),
header(),
aside(),
footer(),
end(),
comment(),
]
what is buildHTML()
and runHTML()
?
with buildHTML()
you can generate your html file and your htmlfilename is : Pyhtml.html
with runHTML()
you can save html codes in variable.
tip: buildHTML()
it must be in the last line.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.