]> git.pld-linux.org Git - projects/pld-ftp-admin.git/blob - cgi-bin/index.py
more python3 readiness
[projects/pld-ftp-admin.git] / cgi-bin / index.py
1 #!/usr/bin/env python
2 # vi: encoding=utf-8 ts=8 sts=4 sw=4 et
3
4 from __future__ import print_function
5
6 # Printing errors (no SyntaxErrors though, but that's not a problem)
7 import sys, os
8 sys.stderr=sys.stdout
9
10 contenttypesent=False
11
12 def myexceptionhandler(type, value, traceback):
13     if contenttypesent:
14         print('<pre>')
15         sys.__excepthook__(type, value, traceback)
16         print('</pre>')
17     else:
18         print("Content-Type: text/plain\n")
19         sys.__excepthook__(type, value, traceback)
20     sys.exit(1)
21
22 sys.excepthook=myexceptionhandler
23 # End printing errors
24
25 sys.path.insert(0, '../modules')
26
27 import wwwiface, user
28
29 opts, cks = wwwiface.getopts()
30 u=user.User(cks, opts)
31
32 if u.loggedin:
33     wwwiface.addheader('Logged in: '+u.login)
34     wwwiface.addmenu(file='loggedinmenu')
35     import wwwcmds
36     wwwcmds.handlecmds(opts)
37 else:
38     wwwiface.addheader('Login form')
39     wwwiface.addcontent(file='regform')
40
41 wwwiface.sendhttpheaders()
42 contenttypesent=True
43
44 wwwiface.sendhtml()
45
This page took 0.077785 seconds and 3 git commands to generate.