[luci] luci.http.header don't works
Bryan Mayland
bmayland at leoninedev.com
Tue Apr 24 16:58:19 CEST 2012
The problem is that you're just running a CGI script, not a LuCI
response handler so you can't use luci http (because there's no context,
LuCI isn't even involved). To make a CGI page spit out the right
content type:
#!/usr/bin/lua
print("Content-Type: text/html")
print("") ' header needs to be separated from content by a blank line
print("<b>I am html content</b>")
On 4/24/2012 8:28 AM, Lay András wrote:
> Hello!
>
> ---------------------------------------------------
>
> #!/usr/bin/lua
>
> require'luci.http'
>
> luci.http.prepare_content('text/html; charset=UTF-8')
>
> luci.http.write('Hello world')
>
> ---------------------------------------------------
>
> > From the browser nothing visible, i traced with livehttpheaders, the
> response content-type is text/plain, but no data. I tried the script
> from command line:
>
> root at OpenWrt:/mnt/web/cgi-bin# lua lufi.lua
> lua: attempt to yield across metamethod/C-call boundary
> stack traceback:
> [C]: in function 'yield'
> /usr/lib/lua/luci/http.lua:191: in function 'header'
> /usr/lib/lua/luci/http.lua:205: in function 'prepare_content'
> lufi.lua:5: in main chunk
> [C]: ?
> root at OpenWrt:/mnt/web/cgi-bin#
More information about the luci
mailing list