Initial Commit
This commit is contained in:
commit
432da12f47
|
@ -0,0 +1,5 @@
|
|||
/luarocks
|
||||
/lua
|
||||
/lua_modules
|
||||
/.luarocks
|
||||
*.luac
|
|
@ -0,0 +1,19 @@
|
|||
package = "snarf"
|
||||
version = "dev-1"
|
||||
source = {
|
||||
url = nil
|
||||
}
|
||||
description = {
|
||||
homepage = "https://github.com/Atlas48/snarf-lua",
|
||||
license = "LGPL-3.0-or-later"
|
||||
}
|
||||
dependencies = {
|
||||
"lua >= 5.1",
|
||||
"luasocket >= 3.0rc1-2"
|
||||
}
|
||||
build = {
|
||||
type = "builtin",
|
||||
modules = {
|
||||
snarf = "snarf.lua"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
local http=require "socket.http"
|
||||
function snarf(s,l)
|
||||
local body,code=http.request(s)
|
||||
if code<=400 or code>=599 then
|
||||
error(code)
|
||||
elseif code<=300 or code>=399 then
|
||||
print("Redirects not currently implemented")
|
||||
error(code)
|
||||
end
|
||||
|
||||
local f=assert(io.open(l))
|
||||
f:write(body)
|
||||
f:close()
|
||||
end
|
||||
return snarf
|
Loading…
Reference in New Issue