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

Mariano Montone marianomontone at gmail.com
Sat Jun 15 20:56:17 PDT 2024


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, enterFeature 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.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20240616/5b30701f/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: WebClientTest.st
Type: application/vnd.sailingtracker.track
Size: 1110 bytes
Desc: not available
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20240616/5b30701f/attachment.st>


More information about the Cuis-dev mailing list