require('luci.util') local nx_redir = false function http_date(time) return os.date('!%a, %d %b %Y %H:%M:%S GMT', time) end function handle_request(env) local send = uhttpd.send if env.REQUEST_URI == '/' then -- NintendoWiFi if nx_redir then send('Status: 302 Found\r\n') send('Location: https://www.bing.com/\r\n\r\n') else local date = http_date(os.time()) send('Status: 200 OK\r\n') send('Content-Length: 2\r\n') send('Expires: %s\r\n' % date) send('Cache-Control: max-age=0, no-cache, no-store\r\n') send('Pragma: no-cache\r\n') send('Date: %s\r\n' % date) send('X-Organization: Nintendo\r\n') send('Content-Type: text/plain\r\n\r\nok') end elseif env.REQUEST_URI == '/generate_204' then -- Android generate_204 send('Status: 204 No Content\r\n') send('Date: %s\r\n\r\n' % http_date(os.time())) end end