[luci] How to instantiate a Request object

Duy Nguyen nkduy2010 at gmail.com
Wed Aug 22 04:47:24 CEST 2012


Hi,

I want to write a module which has a function named "check_ip", which will
go through a list of Facebook IPs to check if there is any IP is not used
to delete it from the list. I used "luci.lucid.http.handler.luci" module
and its function "handle_GET(request)". But I received an error: "attempt
to index local 'env' (a nil value)". I know that I have to give the
"handle_GET" function a Request object, but I don't know how to create that
one.

The Facebook IP list is like the following:
            "www-slb-10-05-prn1.facebook.com",
            "www-slb-10-06-prn1.facebook.com",
            "www-slb-10-08-prn1.facebook.com",
            "www-slb-10-12-prn1.facebook.com"

The function I have written looks like the following: (this one just print
out the code because I want to test if the function works)
function
check_ip()

    local uci = require
"luci.model.uci".cursor()
    local ips =
{}

    ips =
uci:get_list("abc","facebook","ips")

    local luci = require
"luci.lucid.http.handler.luci".Luci()
    for i=1,# ips
do

        local code, header_table, response =
luci:handle_GET("https://"..ips[i])


print(code)


end

end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.subsignal.org/pipermail/luci/attachments/20120822/10689420/attachment.html>


More information about the luci mailing list