| 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
| #!/usr/bin/python
print "Content-Type: text/html" # HTML is following
print
import sys,traceback,time,cgi
import inspect
sys.stderr=sys.stdout
try:
# lecture du fichier html
root="/data/www/s/e/ps.tuxfamily.org/"
file=open("%s/html/template.html"%(root))
text=file.read()
# mise en place des variables
titre="Titre de la page"
date=time.strftime("%d/%m/%Y")
heure=time.strftime("%H heures %M minutes %S secondes")
# affichage avec % magique !
print text % {"titre":titre,"date":date,"heure":heure}
# affichage du template original
print "<hr>Source du template html :<br><pre>%s</pre>"%cgi.escape(text)
# affichage du source
source=open(sys.argv[0])
print "<hr><pre>%s</pre>"%(cgi.escape(source.read()))
except:
print ("<pre>")
traceback.print_exc()
print ("</pre>") |