start on HTTP client
This commit is contained in:
parent
fdd87c5eda
commit
f7ab5dd291
|
@ -59,7 +59,8 @@ comprehend and modify the programs they use. If it's not clear how to provide
|
|||
that experience for some kinds of Lua programs, I'd rather disable support for
|
||||
them in Teliva and let people use regular Lua. Or other platforms!
|
||||
|
||||
- This approach doesn't make sense for batch programs, I think.
|
||||
- This approach doesn't make sense for batch programs, I think. I also don't
|
||||
yet have a good story for building server programs in this way.
|
||||
|
||||
- I don't know how to obtain a simple, shallow graphics stack, so there's no
|
||||
support for graphics at the moment.
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
teliva_program = {
|
||||
main = [==[
|
||||
function main()
|
||||
socket.http.get("http://example.com")
|
||||
curses.getch()
|
||||
end]==],
|
||||
}
|
8
json.tlv
8
json.tlv
|
@ -1,8 +0,0 @@
|
|||
teliva_program = {
|
||||
main = [==[
|
||||
function main()
|
||||
local x = json.decode("[10, 20, 30]")
|
||||
curses.mvaddstr(5, 5, tostring(x[1]))
|
||||
curses.getch()
|
||||
end]==],
|
||||
}
|
27
network.tlv
27
network.tlv
|
@ -1,27 +0,0 @@
|
|||
teliva_program = {
|
||||
main = [==[
|
||||
function main()
|
||||
local server = assert(socket.bind("*", 8080))
|
||||
server:settimeout(1)
|
||||
curses.mvaddstr(1, 1, "Server bound and waiting for one request")
|
||||
curses.refresh()
|
||||
local available_sockets, _, error = socket.select({server}, nil)
|
||||
for _, available_socket in ipairs(available_sockets) do
|
||||
local client = available_socket:accept()
|
||||
curses.mvaddstr(2, 1, "Connection received")
|
||||
curses.refresh()
|
||||
client:settimeout(1)
|
||||
local line, error = client:receive()
|
||||
if error then
|
||||
curses.mvaddstr(3, 1, "error")
|
||||
curses.refresh()
|
||||
server:close()
|
||||
else
|
||||
curses.stdscr():mvaddstr(3, 1, "received:")
|
||||
curses.stdscr():mvaddstr(4, 3, line)
|
||||
curses.refresh()
|
||||
end
|
||||
end
|
||||
curses.getch()
|
||||
end]==],
|
||||
}
|
Loading…
Reference in New Issue