<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hi Mark,</p>
<p>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.</p>
<p>Instead, dispatch to a method, and modify that method.</p>
<pre>initialize
WebServer new</pre>
<pre> <font face="monospace"> listenOn: 3000;</font> </pre>
<pre> addService: '/hello' action: (MessageSend receiver: self selector: #helloWorld:)
</pre>
<p>Then implement the #helloWorld: method and change a piacere.</p>
<p>Also, I would not start the service when you create it. I would
start and stop it manually so you have control.</p>
<p>I attach an example. Look at the class comment.</p>
<p>Cheers,</p>
<p> </p>
<p> Mariano <br>
<br>
</p>
<div class="moz-cite-prefix">El 14/6/24 a las 20:05, Mark Volkmann
via Cuis-dev escribió:<br>
</div>
<blockquote type="cite"
cite="mid:CAFfRWnU4QQ1L+TVn_H+PaqjKRymyR1pTP-65=bqxL9mfXpxchQ@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">I'm using the <font face="monospace">WebServer</font>
class in the <font face="monospace">WebClient</font> 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.
<div>
<div><br>
</div>
<div>1. In a Workspace, enter<span
class="gmail-Apple-converted-space"> </span><font
face="monospace">Feature require: 'WebClient'</font><span
class="gmail-Apple-converted-space"> </span>and "Do it".</div>
</div>
<div>2. Define a class with a name like <font face="monospace">TestServer</font>.</div>
<div>3. An an instance method named <font face="monospace">initialize</font>
containing the following:</div>
<div><br>
</div>
<div><font face="monospace">initialize<br>
<br>
WebServer new<br>
listenOn: 3000;<br>
addService: '/' action: [ :req | req
send200Response: 'Hello World!' ]</font></div>
<div><br>
</div>
<div>4. In the Workspace, enter <font face="monospace">TestServer
new</font> and "Do it".<br>
</div>
<div>5. In a web browser, browse localhost:3000 and verify that
Hello World! is displayed.</div>
<div>6. In the <font face="monospace">initialize</font> method,
change "Hello World!" to anything else and save the change.</div>
<div>7. What can you do now so the new text appears when you
browse that URL?<br>
<div><br>
</div>
<div>I have tried opening a Process Browser window, killing
the "WebServer's listener process", and restarting the
server from the Workspace by running <font face="monospace">TestServer
new</font> 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.</div>
<div>
<div><br>
</div>
<span class="gmail_signature_prefix">-- </span><br>
<div dir="ltr" class="gmail_signature"
data-smartmail="gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div dir="ltr">
<div><font face="arial, helvetica, sans-serif">R.
Mark Volkmann</font></div>
<div><span
style="font-size:12.8000001907349px"><font
face="arial, helvetica, sans-serif">Object
Computing, Inc.</font></span></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
<fieldset class="moz-mime-attachment-header"></fieldset>
</blockquote>
</body>
</html>