[Cuis-dev] updating WebServer code - begging for help

Mark Volkmann r.mark.volkmann at gmail.com
Sun Jun 16 14:56:59 PDT 2024


Thank you so much Mariano! That was very helpful!

On Sat, Jun 15, 2024 at 10:56 PM Mariano Montone via Cuis-dev <
cuis-dev at lists.cuis.st> wrote:

> Hi Mark,
>
> don't put the code that does the response inside a block. Once you pass
> that block you cannot access it and change it anymore.
>
> Instead, dispatch to a method, and modify that method.
>
> initialize
>
>    WebServer new
>
>      listenOn: 3000;
>
>       addService: '/hello' action: (MessageSend receiver: self selector: #helloWorld:)
>
>
> Then implement the #helloWorld: method and change a piacere.
>
> Also, I would not start the service when you create it. I would start and
> stop it manually so you have control.
>
> I attach an example. Look at the class comment.
>
> Cheers,
>
>     Mariano
>
> El 14/6/24 a las 20:05, Mark Volkmann via Cuis-dev escribió:
>
> I'm using the WebServer class in the WebClient package. Any time I change
> a "route", I have to restart the VM in order for the change to take effect.
> There must be some way around this. Here's a very simple way to duplicate
> what I'm seeing.
>
> 1. In a Workspace, enter Feature require: 'WebClient' and "Do it".
> 2. Define a class with a name like TestServer.
> 3. An an instance method named initialize containing the following:
>
> initialize
>
>     WebServer new
>         listenOn: 3000;
>         addService: '/' action: [ :req | req send200Response: 'Hello
> World!' ]
>
> 4. In the Workspace, enter TestServer new and "Do it".
> 5. In a web browser, browse localhost:3000 and verify that Hello World! is
> displayed.
> 6. In the initialize method, change "Hello World!" to anything else and
> save the change.
> 7. What can you do now so the new text appears when you browse that URL?
>
> I have tried opening a Process Browser window, killing the "WebServer's
> listener process", and restarting the server from the Workspace by running TestServer
> new again, but that doesn't work. The only thing that works for me is
> saving and restarting the image, which of course is very tedious to do
> after every code change.
>
> --
> R. Mark Volkmann
> Object Computing, Inc.
>
> --
> Cuis-dev mailing list
> Cuis-dev at lists.cuis.st
> https://lists.cuis.st/mailman/listinfo/cuis-dev
>


-- 
R. Mark Volkmann
Object Computing, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20240616/c72080d9/attachment.htm>


More information about the Cuis-dev mailing list