-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmake-html.py
95 lines (78 loc) · 1.79 KB
/
make-html.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#! /usr/bin/env python
import os
try:
os.mkdir('html')
except OSError:
# already exists
pass
try:
os.mkdir('html/subdir')
except OSError:
# already exists
pass
###
fp = open('html/index.html', 'w')
print >>fp, """<html>
<head>
<title>My favorite page.</title>
<style type='text/css'>
h1 {color:red;}
body {
font-size: 14px;
}
</style>
<script>
function myFunction()
{
alert("Hello! I am an alert box!");
}
</script>
</script>
</head>
<body>
"""
print >>fp, "<h1>Hello, world.</h1>"
print >>fp, "Hello, world.<p><a href='link.html'>this is a relative link</a>"
print >>fp, """
<p>
<a href='subdir/table.html'>Here is a link</a> to a file in subdir/:
<p>
<input type="button" onclick="myFunction()" value="Show alert box" />
"""
print >>fp, """
</body>
</html>
"""
fp.close()
###
fp = open('html/subdir/table.html', 'w')
print >>fp, """
<ul>
<li> Unordered
<li> list
</ul>
<p>
<ol>
<li> Ordered
<li list
</ol>
<p>
A table:
<table>
<tr>
<td>Row 1, col 1</td>
<td>Row 1, col 2</td>
</tr>
<tr>
<td>Row 2, col 1</td>
<td>Row 2, col 2</td>
</tr>
<tr><td colspan=1>Note, you can nest <a href='table.html'>things like links</a> in tables</td></tr>
</table>
"""
fp.close()
###
fp = open('html/catastrophe.html', 'w')
print >>fp, """
<tr><td> <h3>This <width="25%" align="left"></td></tr><tr><td> <h3>is <width="25%" align="left"></td></tr><tr><td> <h3>an <width="25%" align="left"></td></tr><tr><td> <h3>ascending <width="25%" align="left"></td></tr><tr><td> <h3>catastrophe <width="25%" align="left"></td></tr><tr><td> <h3>QUICK! <width="25%" align="left"></td></tr><tr><td> <h3>close <width="25%" align="left"></td></tr><tr><td> <h3>the <width="25%" align="left"></td></tr><tr><td> <h3>h3 <width="25%" align="left"></td></tr><tr><td> <h3>tags! <width="25%" align="left"></td></tr>
"""