标签:ofo umask config boot 实现 trap ref put ace
下面是年前的一个tornado小型项目
前端效果主要是参照bootstrap官网模板
后端数据主要是通过ajax,post, get实现数据参数传输
注意点:1. tornado的csrf_token写法形式与django有区别
2. tornado在服务器上的挂载方式也略有区别
项目代码很简单,就不班门弄斧了。直接上注意点:
<form class="form-signin"> {% module xsrf_form_html() %} //csrf_token <img class="mb-4" src="/static/img/god.ico" alt="" width="72" height="72"> <h1 class="h3 mb-3 font-weight-normal">Please sign in</h1> <label for="inputEmail" class="sr-only">Username</label> <input type="text" id="inputEmail" class="form-control" name="username" placeholder="Username" required autofocus> <label for="inputPassword" class="sr-only">Password</label> <input type="password" id="inputPassword" class="form-control" name="password" placeholder="Password" required> <div class="checkbox mb-3"> <label> <input type="checkbox" id="Choice" value="remember-me" checked> Remember me </label> </div> <input class="btn btn-lg btn-primary btn-block" id="login" type="button" value="Sign in"> <span class="error"></span> <p class="mt-5 mb-3 text-muted">© 2019-2010</p> </form>
$("#login").click( function () { var n = $(‘#Choice‘).prop(‘checked‘); $.ajax({ url: "", type: ‘post‘, data: { remeber: n, username: $("[name=‘username‘]").val(), password: $("[name=‘password‘]").val(), _xsrf: $("[name=‘_xsrf‘]").val() }, success: function (data) { if (data === "1") { console.log("ok"); location.href = ‘/LoginWin‘ } else { $(".error").text("Error: 请检查 账号 or 密码 是否正确").css({"color": "red", "margin-left": "10px"}); setTimeout(function () { $(".error").text(‘‘); }, 1000) } } }) })
def daemon(): import os try: pid = os.fork() if pid > 0: return pid except OSError as error: return -1 os.setsid() os.umask(0) try: pid = os.fork() if pid > 0: return pid except OSError as error: return -1 sys.stdout.flush() sys.stderr.flush() si = open("/dev/null", "r") so = open("/dev/null", "ab") se = open("/dev/null", "ab", 0) os.dup2(si.fileno(), sys.stdin.fileno()) os.dup2(so.fileno(), sys.stdin.fileno()) os.dup2(se.fileno(), sys.stdin.fileno()) return 0 def main(): app = Application() # 项目启动 httpServer = tornado.httpserver.HTTPServer(app) # 项目启动 httpServer.bind(config.options["port"]) # 项目启动 httpServer.start(1) # 项目启动 tornado.ioloop.IOLoop.current().start() # 项目启动 pid = daemon() # fork进程 if pid: return pid if __name__ == ‘__main__‘: main()
标签:ofo umask config boot 实现 trap ref put ace
原文地址:https://www.cnblogs.com/cjj-zyj/p/10360946.html