Ejemplo n.º 1
0
# -*- coding: utf-8 -*-

import tornado.ioloop
import tornado.web

import os
import web
import dbconn
dbconn.register_dsn("host=localhost dbname=srdb user=srdbo password=pass")

from handlers import *

settings = {"static_path": os.path.join(os.getcwdu(), 'pages'), "debug": True}

handlers = [(r"/s/user/([0-9]+)?", UserRestHandler),
            (r'/(.*)', web.HtplHandler)]

application = tornado.web.Application(handlers, **settings)

if __name__ == "__main__":
    import logging
    logging.basicConfig(
        format='%(asctime)s %(name)s:%(levelname)s:%(message)s',
        datefmt='%H%M%S',
        level=logging.DEBUG)

    application.listen(8888)
    server = tornado.ioloop.IOLoop.instance()
    #tornado.ioloop.PeriodicCallback(lambda: None, 500, server).start()
    server.start()
Ejemplo n.º 2
0
import os
BASE_DIRS = os.path.dirname(__file__)  #路径优化

#数据库配置
import dbconn
dbconn.register_dsn("host=localhost dbname=StaticInfo user=postgres password="******"port": 9999}

#配置
settings = {
    "static_path": os.path.join(BASE_DIRS, "static"),
    "template_path": os.path.join(BASE_DIRS, "templates"),
    "debug": True
}
Ejemplo n.º 3
0
# -*- coding: utf-8 -*-

import tornado.ioloop
import tornado.web

import os
import web
import dbconn
dbconn.register_dsn("host=localhost dbname=srdb user=srdbo password=pass")

from handlers import *

settings = {
    "static_path": os.path.join(os.getcwdu(), 'pages'),
    "debug": True
}

handlers = [
    (r"/s/user/([0-9]+)?", UserRestHandler),
    (r'/(.*)', web.HtplHandler)
]

application = tornado.web.Application(handlers, **settings)


if __name__ == "__main__":
    import logging
    logging.basicConfig(
        format='%(asctime)s %(name)s:%(levelname)s:%(message)s', 
        datefmt='%H%M%S', level=logging.DEBUG)
Ejemplo n.º 4
0
# -*- coding: utf-8 -*-

import tornado.ioloop
import tornado.web

import os
import web
import dbconn
dbconn.register_dsn("host=localhost dbname=datebase user=llms password=pass")

from handlers import *

settings = {"static_path": os.path.join('pages'), "debug": True}

application = tornado.web.Application(
    [
        (r'/', HeadHandler),  #登录页面
        (r'/login', LoginHandler),  #登录
        (r'/Error', ErrorHandler),  #密码登录错误提示
        (r'/Administrator', AdministratorHandler),  #管理员登陆后主页面
        (r"/Studentpage/([0-9]+)?", StudentpageHandler),  #学生登陆主后页面
        (r"/Teacherpage/([0-9]+)?", TeacherpageHandler),  #教师登陆后页面
        (r"/tmission/([0-9]+)?", TmissionRestHandler),  #管理员登陆后教师任务
        (r"/plan/([0-9]+)?", PlanRestHandler),
        (r"/teacher/([0-9]+)?", TeacherRestHandler),
        (r"/course/([0-9]+)?", CourseRestHandler),  #管理员登陆后学生清单
        (r"/student/([0-9]+)?", StudentRestHandler),  #管理员登陆后学生清单
        (r"/major/([0-9]+)?", MajorRestHandler),  #管理员登陆后学生清单
        (r"/grade/([0-9]+)?", GradeRestHandler),  #管理员登陆后学生清单
        (r'/teacher/([0-9]+)?', TeacherRestHandler),  #管理员登陆后教师信息
        (r"/s_grade/([0-9]+)?", S_GradeRestHandler),  #学生界面——成绩表
Ejemplo n.º 5
0
# -*- coding: utf-8 -*-
#数据库文件,定义了数据操作的所有处理器
import tornado.ioloop
import tornado.web
import dbconn

dbconn.register_dsn(
    "host=localhost dbname=studentMS user=admin01 password=pass")


class BaseReqHandler(tornado.web.RequestHandler):
    def db_cursor(self, autocommit=True):
        return dbconn.SimpleDataCursor(autocommit=autocommit)


#定位登录界面
class MainHandler(BaseReqHandler):
    def get(self):
        self.set_header("Content-Type", "text/html; charset=UTF-8")
        self.render("index.html", title="管理学院课程管理系统")


#检查登录用户是学生、教师、管理员
#如果登录用户是学生,定位到/student界面,登录用户是教师,定位到/teacher界面,登录用户是管理员,定位/admin界面
class CheckHandler(BaseReqHandler):
    def post(self):
        login_no = self.get_argument("login_no")
        if login_no[0] == 's':
            self.redirect("/student")
        elif login_no[0] == 'a':
            self.redirect("/admin")