srvcnf.py 2.38 KB
#!/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()