From 7d93ac18828edac0f240a5ff5a15b42f4eb2a8f5 Mon Sep 17 00:00:00 2001 From: crc Date: Sun, 19 Nov 2017 21:27:51 +0000 Subject: [PATCH] glossary: http is working FossilOrigin-Name: 651034c4a939e686c685c196f0ad7596ab99fd3f01feb03fd153efc66c987d9b --- glossary.forth | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/glossary.forth b/glossary.forth index 3842dcd..fcc15a3 100755 --- a/glossary.forth +++ b/glossary.forth @@ -455,11 +455,20 @@ And then the actual top level server. 'Selector d:create #1024 allot +:http:display (-) + #0 'words.tsv [ s:keep !SourceLine dup-pair eq? [ '
 puts display-result '
puts ] if n:inc ] file:for-each-line drop-pair ; + +:handle-http + &Selector ASCII:SPACE s:tokenize #1 set:nth fetch + dup s:length #1 eq? + [ drop http:list-words ] + [ n:inc s:to-number http:display ] choose ; + :gopher:serve &Selector gets &Selector #0 #5 s:substr '/desc [ &Selector ASCII:SPACE s:tokenize #1 set:nth fetch s:chop s:keep !Target gopher:display ] s:case - 'GET_/ [ 'HTTP/1.0_200_OK\nContent-Type:_text/html\n\n s:with-format puts http:list-words ] s:case + 'GET_/ [ 'HTTP/1.0_200_OK\nContent-Type:_text/html\n\n s:with-format puts handle-http ] s:case drop gopher:list-words ; ~~~