return from lua

34 views
Skip to first unread message

Vinu Prasad

unread,
Oct 5, 2017, 6:24:58 AM10/5/17
to Lua BR
I am using lua as server page for the authentication. after the authentication i wnt to retaun a value to the angular js. I simply cheked for for a string retun , bbut it will not work ..plaese anybody knows how to solve it ? How to return the values..

this is my lua script

require "string"
require 'apache2'
--require "json"
json = require 'json'
function handle(r)
local POST, POSTMULTI = r:parsebody()
local name = POST['username']
local user =""
r.content_type = "text/plain"
local result = {}
local file1 = io.open("/var/www/html/login/test.json", "r")
 local contents = file1:read( "*all" )
r:puts("" .. contents)
 return "hello"
end

but it is not returned in the angular ...this is the right method for return values.?

Denis Dos Santos Silva

unread,
Oct 5, 2017, 4:23:03 PM10/5/17
to Lua BR
Hi. This links is only for portuguese brazilian.

about you question:

-- did you using mod_lua* from apache2 ?

-- http response "returns":
- header
- body

can't be 'return' a value to angular.


Vinu Prasad

unread,
Oct 6, 2017, 12:49:40 AM10/6/17
to Lua BR
Hiii....Denis

Thanks for the replay. Yes I am using Mod_lua apache2. Is Mod_lua doesn't return value to angular ?. If there is any other method to return values from mod_lua to angular . And thanks for the documentation link attached.

Denis Dos Santos Silva

unread,
Oct 6, 2017, 10:20:42 AM10/6/17
to Lua BR
Vinu the scope are different.
When angular and/or browser request a call to server (ajax, get, post, ...) it will retrive the * http header|body * not a 'value'. 
An value can be returned, but, using http status code (like 200, 201, ...)

checkout mod_lua documentation have several examples.

Addenum:  mod_lua alternatives --> http://lua.space/webdev/the-best-lua-web-frameworks <--



Em quinta-feira, 5 de outubro de 2017 07:24:58 UTC-3, Vinu Prasad escreveu:

Vinu Prasad

unread,
Oct 6, 2017, 11:43:00 PM10/6/17
to lua...@googlegroups.com
Hiii Denis... Thank you for your valid information ,  and the mod_lua documentation link. I will go through it.

--
Você recebeu essa mensagem porque está inscrito em um tópico no grupo "Lua BR" dos Grupos do Google.
Para cancelar inscrição nesse tópico, acesse https://groups.google.com/d/topic/lua-br/-jV19u7SN1Y/unsubscribe.
Para cancelar inscrição nesse grupo e todos os seus tópicos, envie um e-mail para lua-br+unsubscribe@googlegroups.com.
Acesse esse grupo em https://groups.google.com/group/lua-br.
Para mais opções, acesse https://groups.google.com/d/optout.



--
Vinu Prasad
 
Reply all
Reply to author
Forward
0 new messages