d.zivertas
2021-1-13 09:09:22

@d.zivertas has joined the channel


spdegabrielle
2021-1-13 11:11:56

Is there a collection of macro exercises for practice/skills building ?


sorawee
2021-1-13 11:22:23

Racket Summer Schools have several macro exercises.


soegaard2
2021-1-13 11:43:35

curiouslearn
2021-1-13 14:37:22

Any suggestions on how to get started with building api websites with Racket? I am a beginner to Racket, so don’t have much experience with it. I did a search here and Koyo came up. I am going to look through the video, but it seems like a complete framework with a lot of functionality. It is a little overwhelming for a beginner to Racket and someone who has used more basic frameworks like Flask (not Django, not Ruby-onRails). Would appreciate any comments on where I should start. Also, what do you think of Jesse Alama’s book. Is that good? I tried to click to get the sample chapter, but the link does not work.


curiouslearn
2021-1-13 14:37:28

Thanks for your help.


soegaard2
2021-1-13 14:44:02

soegaard2
2021-1-13 14:45:49

Start with listit which has the most basic version. In listit2 a few things have been addded. In listit3 more things are added. In listit4 even more things.

And then the actual code in production: https://github.com/soegaard/racket-stories


soegaard2
2021-1-13 14:47:16

The repo is called “web tutorial”, but the tutorial unfortunately didn’t spontaneous materialize.


soegaard2
2021-1-13 14:48:13

That said, Koyo is a much more professional web-framework. I would love to see some tutorials for it.


curiouslearn
2021-1-13 14:57:51

Thank you very much @soegaard2. Will look at these links. Racket is lucky to have a helpful member like you.


soegaard2
2021-1-13 15:00:32

If you clone the repo, you ought to start the first example with: cd listit racket server.rkt


jesse697
2021-1-13 17:27:15

@curiouslearn :wave: can you let me know where the link is?


notjack
2021-1-13 18:05:40

kellysmith12.21
2021-1-13 18:43:37

Is <https://docs.racket-lang.org/peg/index.html?q=peg|this PEG library> the one described in the paper, “Macros for Domain-Specific Languages”?


samth
2021-1-13 18:47:26

No, I don’t think so


samdphillips
2021-1-13 18:48:47

spdegabrielle
2021-1-13 18:59:41

I’ll pass it on


curiouslearn
2021-1-13 19:25:54

Hi Jesse,


curiouslearn
2021-1-13 19:26:11

The link is here: https://gumroad.com/l/serverracket when you go to the Sample Chapter section.


curiouslearn
2021-1-13 19:34:06

Hi, I am working through “More: Systems Programming with Racket” (https://docs.racket-lang.org/more/). In the examples there, the authors use regex to parse the http request. I want to see what the request looks like to understand what the regex is doing. As the authors state on that site, they are using the regex directly on input stream. How can I can convert the whole input stream to a string and print it out so that I can see the contents of that request? Thank you.


samth
2021-1-13 19:35:11

I think you want port-&gt;string


curiouslearn
2021-1-13 19:44:05

Thanks! Yes, that does it. That causes the regex to fail. I suppose it is because the input port is now empty. Will check how to deal with it. Passing the string to regex does not work.


samth
2021-1-13 20:06:44

The way that code uses the input port is stateful, so replicating it on a string will be tricky


notjack
2021-1-13 21:09:57

Eventually I’d like something more stable and less powerful to rely on, so I made a bug https://github.com/jackfirth/resyntax/issues/19\|https://github.com/jackfirth/resyntax/issues/19 @ryanc your thoughts on this would be greatly appreciated


curiouslearn
2021-1-13 21:24:03

Thank you @samth. Another thing I don’t understand is why removing the regex-match line in the code below, causes the requests to fail. It appears that the match not used for anything when responding.

(define (handle in out) ; Discard the request header (up to blank line): (regexp-match #rx"(\r\n\|^)\r\n" in) ; Send reply: (display "HTTP/1.0 200 Okay\r\n" out) (display "Server: k\r\nContent-Type: text/html\r\n\r\n" out) (display "&lt;html&gt;&lt;body&gt;Hello, world!&lt;/body&gt;&lt;/html&gt;" out))


greg
2021-1-14 02:28:49

The regexp-match reads the rest of the request. If the client waits to finish writing the request, before trying to read the response, that will never happen?


greg
2021-1-14 02:33:15

I understand you want to see the request. Instead of trying to remove the regexp-match expressions from the example, would it help if you simply wrap each of them in println?


greg
2021-1-14 02:33:50

e.g. change (regexp-match #rx"(\r\n\|^)\r\n" in) to (println (regexp-match #rx"(\r\n\|^)\r\n" in))


greg
2021-1-14 02:36:15

@curiouslearn


jesse697
2021-1-14 05:02:51

ah, thanks! Silly mistake on my part