docs: add curl examples
This commit is contained in:
parent
a634528d02
commit
a7e7972033
@ -1,3 +1,13 @@
|
|||||||
|
print([[
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
examples:
|
||||||
|
===============================================================================
|
||||||
|
curl localhost:3000
|
||||||
|
=> Hello, World!
|
||||||
|
===============================================================================
|
||||||
|
]])
|
||||||
|
|
||||||
local app = create_app()
|
local app = create_app()
|
||||||
|
|
||||||
app:get("/", function(req, res)
|
app:get("/", function(req, res)
|
||||||
|
|||||||
@ -1,3 +1,10 @@
|
|||||||
|
print([[
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
Open your browser and go to http://localhost:3000
|
||||||
|
===============================================================================
|
||||||
|
]])
|
||||||
|
|
||||||
local app = create_app()
|
local app = create_app()
|
||||||
|
|
||||||
app:get("/", function(req, res)
|
app:get("/", function(req, res)
|
||||||
|
|||||||
@ -1,12 +1,21 @@
|
|||||||
|
print([[
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
examples:
|
||||||
|
===============================================================================
|
||||||
|
curl -F "test=@README.md" localhost:3000/submit
|
||||||
|
===============================================================================
|
||||||
|
]])
|
||||||
|
|
||||||
local app = create_app()
|
local app = create_app()
|
||||||
|
|
||||||
app:post("/", function(req,res)
|
app:post("/", function(req, res)
|
||||||
if req.parts.myfile == nil then
|
if req.parts.test == nil then
|
||||||
res.status = 400
|
res.status = 400
|
||||||
res.body = "Missing myfile field"
|
res.body = "Missing myfile field"
|
||||||
return res
|
return res
|
||||||
end
|
end
|
||||||
fs:write("yololo.txt", req.parts.myfile.content)
|
fs:write("yololo.txt", req.parts.test.content)
|
||||||
return res
|
return res
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,18 @@
|
|||||||
|
print([[
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
examples:
|
||||||
|
===============================================================================
|
||||||
|
curl localhost:3000
|
||||||
|
===============================================================================
|
||||||
|
]])
|
||||||
|
|
||||||
|
|
||||||
local lib = require("require_lib")
|
local lib = require("require_lib")
|
||||||
|
|
||||||
local app = create_app()
|
local app = create_app()
|
||||||
|
|
||||||
app:get("/", function(req,res)
|
app:get("/", function(req, res)
|
||||||
return lib.identity(res)
|
return lib.identity(res)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,25 @@
|
|||||||
|
print([[
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
examples:
|
||||||
|
===============================================================================
|
||||||
|
curl localhost:3000
|
||||||
|
=> Not Found
|
||||||
|
|
||||||
|
curl localhost:3000/42
|
||||||
|
=> {"data":"42"}
|
||||||
|
|
||||||
|
curl -d "test=hello&test2=world" localhost:3000/submit
|
||||||
|
=> hello world
|
||||||
|
|
||||||
|
curl localhost:3000/admin
|
||||||
|
=> Admin
|
||||||
|
|
||||||
|
curl localhost:3001
|
||||||
|
=> Admin
|
||||||
|
===============================================================================
|
||||||
|
]])
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
Admin Section
|
Admin Section
|
||||||
]]
|
]]
|
||||||
@ -20,9 +42,7 @@ app:get("/:segment", function(req, res)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
app:post("/submit", function(req, res)
|
app:post("/submit", function(req, res)
|
||||||
for k,v in pairs(req.form) do
|
res.body = req.form.test .. " " .. req.form.test2
|
||||||
print(k,v)
|
|
||||||
end
|
|
||||||
return res
|
return res
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user