A server-side web framework written in Forth. http://www.1-9-9-1.com
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

38 linhas
919B

  1. \ 1991
  2. include unix/socket.fs
  3. : read-request ( socket -- addr u ) pad 4096 read-socket ;
  4. : send-response ( addr u socket -- )
  5. dup >R write-socket R> close-socket ;
  6. : start-server { server client }
  7. begin
  8. server 255 listen
  9. server accept-socket to client
  10. client read-request type s\" HTTP/1.1 200 OK\n Content-Type: text/html\n\n fffff" client send-response
  11. again ;
  12. : 1991: ( port -- ) create-server 0 start-server ;
  13. : 1991/ ( "<path> <word>" -- )
  14. \ TODO store each path => xt and execute within
  15. \ handle-server
  16. bl word
  17. cr ." Setting get for " count type
  18. \ TODO handle non-words. Should give the user
  19. \ some compile-/run-time error.
  20. ' \ fetch xt
  21. dup >name
  22. cr ." handler word is " name>string type
  23. cr ." running handler: " execute ;
  24. \ App demo:
  25. : handle-hi ." hi!" ; \ not sure printing is the way to go?
  26. 1991/ hi handle-hi
  27. \ 8080 1991: