]> git.pld-linux.org Git - projects/pld-ftp-admin.git/blame - modules/wwwiface.py
Fix octal constants syntax (python3 compat)
[projects/pld-ftp-admin.git] / modules / wwwiface.py
CommitLineData
1610d209
MM
1# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
2
2ec96333
JR
3from __future__ import print_function
4
1610d209
MM
5import cgi, Cookie, os
6
7menu=[]
8content=[]
9header=[]
10
11def getfile(file):
12 f=open("../html/" + file + ".html", 'r')
13 s=f.read()
14 f.close()
15 return s
16
17def catfile(file):
18 f=open("../html/" + file + ".html", 'r')
2ec96333 19 print(f.read())
1610d209
MM
20 f.close()
21
22def sendhttpheaders():
2ec96333 23 print("Content-Type: text/html\n")
1610d209
MM
24
25def getopts():
26 form = cgi.FieldStorage()
27 opts = {}
28 for key in form.keys():
29 opts[key] = form[key].value
30
31 cookies = {}
32
16b37c0d 33 if 'HTTP_COOKIE' in os.environ:
1610d209
MM
34 c = Cookie.SimpleCookie()
35 c.load(os.environ['HTTP_COOKIE'])
36 for key in c.keys():
37 cookies[key] = c[key].value
38
39 return (opts, cookies)
40
41def sendhtml():
42 catfile('header')
43
2ec96333 44 print('<div id="Header">')
1610d209 45 for i in header:
2ec96333
JR
46 print(i)
47 print('</div>')
1610d209 48
2ec96333 49 print('<div id="Menu">')
1610d209 50 for i in menu:
2ec96333 51 print(i)
1610d209 52 catfile('menufooter')
2ec96333 53 print('</div>')
1610d209 54
2ec96333 55 print('<div id="Content">')
1610d209 56 for i in content:
2ec96333
JR
57 print(i)
58 print('</div>')
1610d209
MM
59
60 catfile('footer')
61
62def addmenu(text=None, file=None):
63 if text:
64 menu.append(text)
65 else:
66 menu.append(getfile(file))
67
68def addheader(text=None, file=None):
69 if text:
70 header.append(text)
71 else:
72 header.append(getfile(file))
73
74def addcontent(text=None, file=None):
75 if text:
76 content.append(text)
77 else:
78 content.append(getfile(file))
79
This page took 1.990526 seconds and 4 git commands to generate.