• 考勤的lua脚本


    ngx.header.content_type = "text/plain;charset=utf-8"
    local cjson = require "cjson"
    
    local request_method = ngx.var.request_method;
    local args = nil;
    args = ngx.req.get_uri_args();
    
    if args["SN"] == nil or args["SN"]=="" then
            ngx.print("{"success":"false","info":"参数SN不能为空!"}");
            return;
    end
    local count=0;
    
    if args["table"]=="ATTLOG" then
        ngx.req.read_body();
        local body = ngx.req.get_body_data()
        local lines=string.split(body,"
    ");
        count=#lines-1;
    
        for i=1,#lines-1 do
            local l=string.split(lines[i],"	");
            local personId=l[1];
            local kqTime=l[2];
        ngx.log(ngx.ERR,"****HuangHai****===>人员id:"..personId,"考勤时间:"..kqTime);
        end 
    end
    
    ngx.say("HTTP/1.1 200 OK");
    ngx.say("Server: DsidealSuperServer/1.9.0");
    local now = os.date("%Y-%m-%d %H:%M:%S", os.time())
    
    ngx.say(now);
    ngx.say("Content-Type: text/plain");
    ngx.say("Connection: close");
    ngx.say("Content-Length:4");
    
    ngx.say("Pragma: no-cache");
    ngx.say("Cache-Control: no-store");
    ngx.say("");
    ngx.say("OK:"..tostring(count));
    
    function string.split(str, delimiter)
        if str==nil or str=='' or delimiter==nil then
            return nil
        end
        
        local result = {}
        for match in (str..delimiter):gmatch("(.-)"..delimiter) do
            table.insert(result, match)
        end
        return result
    end

    vi /usr/local/openresty/nginx/lua/lua_script/kaoqin.lua

    在配置文件中添加如下内容:
      location /iclock/
            {
              content_by_lua_file /usr/local/openresty/nginx/lua/lua_script/kaoqin.lua;
            }
    示例代码在199上。

    查看日志:

    tail -f /usr/local/openresty/nginx/logs/error.log | grep ****HuangHai****

  • 相关阅读:
    【每日一题】740. 删除并获得点数
    【每日一题】1473. 粉刷房子 III
    【每日一题】7. 整数反转
    【每日一题】554. 砖墙
    【每日一题】690. 员工的重要性
    【每日一题】137. 只出现一次的数字 II
    【每日一题】403. 青蛙过河
    【每日一题】633. 平方数之和
    【每日一题】938. 二叉搜索树的范围和
    a_lc_到达终点(数学优化)
  • 原文地址:https://www.cnblogs.com/littlehb/p/5732978.html
Copyright © 2020-2023  润新知