I'm trying to use tcpserver from ucspi-tcp to launch a script that returns a simple web page. My script (hello.lua) is as follows:
#!/usr/bin/env lua
print([[HTTP/1.1 200 OK
Content-Type: text/html
Hello in big font
]])
I launch it with tcpserver -v -rh 0 9000 /path/to/hello.lua
When I use tcpcat myserver 9000
, I get the expected return:HTTP/1.1 200 OK
Content-Type: text/html
Hello in big font
However, when I try to use a webbrowser and point to http:\\myserver:9000
, I get a browser error (in Chrome) Error 101 (net::ERR_CONNECTION_RESET): Unknown error
, even though the tcpserver logging shows a transaction:tcpserver: status 1/40
tcpserver: pid 21672 from
tcpserver: ok 21672
tcpserver: end 21672 status 0
I know I'm missing something basic here, but I can't put the pieces of the puzzle together. Any insight is appreciated! Thanks!
Answer
You need a blank line between the headers and the content:
HTTP/1.1 200 OK
Content-Type: text/html
My title
Hello in big font
No comments:
Post a Comment