srvcnf.py
2.38 KB
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
#!/usr/bin/python3
# -*- coding: UTF-8 -*-# enable debugging
import tornado.ioloop
import tornado.web
import tornado.escape
import tornado
import os.path
import tornado.options
from ncauth.ncauth_logout import ncauth_logout
from ncauth.ncauth_user import ncauth_user
from mailsrv.mailcnf_user import mailcnf_user
from mailsrv.mailcnf_domain import mailcnf_domain
from mailsrv.mailcnf_alias import mailcnf_alias
from mailsrv.mailcnf_bcc import mailcnf_bcc
from mailsrv.mailcnf_posttools import mailcnf_posttools
from base.base_about import base_about
class srvcnf(tornado.web.RequestHandler):
def get_current_user(self):
return self.get_secure_cookie("user")
@tornado.web.authenticated
def get(self):
nav=all
loader =tornado. template.Loader(os.path.join(os.path.dirname(__file__), "templates"))
navigation=loader.load("navigation.html").generate(nav=nav)
self.render('base.html', navigation=navigation)
@tornado.web.authenticated
def post(self):
module= self.get_argument("module", None, False)
mainfnc= self.get_argument("mainfnc", None, False)
nav=all
subnav=all
loader =tornado. template.Loader(os.path.join(os.path.dirname(__file__), "templates"))
navigation=loader.load("navigation.html").generate(nav=nav)
subnavigation=loader.load("subnav_"+module+"_"+mainfnc+".html").generate(subnav=subnav)
self.render('base.html', navigation=navigation, subnavigation=subnavigation)
def make_app():
return tornado.web.Application(
handlers=[
(r"/", srvcnf),
(r"/login", ncauth_user),
(r"/logout", ncauth_logout),
(r"/mailcnf/user" , mailcnf_user),
(r"/mailcnf/domain" , mailcnf_domain),
(r"/mailcnf/alias" , mailcnf_alias),
(r"/mailcnf/bcc" , mailcnf_bcc),
(r"/mailcnf/posttools" , mailcnf_posttools),
(r"/base/about" , base_about),
],
login_url="/login",
logout_url="/logout",
template_path=os.path.join(os.path.dirname(__file__), "templates"),
static_path=os.path.join(os.path.dirname(__file__), "static"),
debug=True,
cookie_secret='axcermnogtlehdded12334'
)
if __name__ == "__main__":
app = make_app()
app.listen(6611)
tornado.ioloop.IOLoop.current().start()