about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-11-21 14:33:50 -0800
committerKartik K. Agaram <vc@akkartik.com>2021-11-21 14:33:57 -0800
commitf7ab5dd291f302c0fb97a2be0a11a06ed2bb6661 (patch)
tree9bc4117005137281e4bbef64ab412d72da62af63
parentfdd87c5eda35dc4918f50ab41e1defde6ebf2411 (diff)
downloadteliva-f7ab5dd291f302c0fb97a2be0a11a06ed2bb6661.tar.gz
start on HTTP client
-rw-r--r--README.md3
-rw-r--r--chesstv.tlv7
-rw-r--r--json.tlv8
-rw-r--r--network.tlv27
4 files changed, 9 insertions, 36 deletions
diff --git a/README.md b/README.md
index b56ebe9..b222ad9 100644
--- a/README.md
+++ b/README.md
@@ -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.
diff --git a/chesstv.tlv b/chesstv.tlv
new file mode 100644
index 0000000..68aa90b
--- /dev/null
+++ b/chesstv.tlv
@@ -0,0 +1,7 @@
+teliva_program = {
+  main = [==[
+function main()
+  socket.http.get("http://example.com")
+  curses.getch()
+end]==],
+}
diff --git a/json.tlv b/json.tlv
deleted file mode 100644
index 5513b69..0000000
--- a/json.tlv
+++ /dev/null
@@ -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]==],
-}
diff --git a/network.tlv b/network.tlv
deleted file mode 100644
index c4c2d10..0000000
--- a/network.tlv
+++ /dev/null
@@ -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]==],
-}